
Figure 14-3: Creating a Visual Basic .NET Web service project
Visual Studio .NET creates a stub of a sample HelloWorld service, which you can use as a starting point. Notice in the following code that the System.Web.Services namespace is imported and the WebService and WebMethod attributes are added to our application. The rest of the code is the same as in our Visual Studio 6.0 service, so I've left some of it out.
Imports System.Web.Services
<WebService(Namespace := "http://tempuri.org/")> _
Public Class Service1
Inherits System.Web.Services.WebService
' WEB SERVICE EXAMPLE
' The HelloWorld() example service returns the string Hello World.
' To build, uncomment the following lines then save and build the
' project.
' To test this web service, ensure that the .asmx file is the
' start page and press F5.
'
'<WebMethod()> Public Function HelloWorld() As String
' HelloWorld = "Hello World"
' End Function
<WebMethod()> Public Function
GetFreeBusy(ByVal strDirURL As String, _
ByVal strUserNames As String, ByVal strStartDate As String, ByVal _
strEndDate As String, ByVal strInterval As String) As Stringheight="15" width="10" 0">
End Function
Private Function PrivGetFreeBusy(ByVal strUserName as String, _
ByVal strDirURL as String, _
ByVal strStartDate as String, _
ByVal strEndDate as String, _
ByVal strInterval as String) as String
End Function
End Class
To test the .NET version of our Web service, all we do is make sure our .asmx file is the start page for our application and then run the application. Visual Studio .NET will then launch our application. Figure 14-4 shows the test page for our Web service. We can fill in the parameters and try the service to see if it works.
