VSM - July 2002 Getting Started column
Create and Consume XML Web Services
Stan Schultes - stan@vbnetexpert.com

The sample code for this column includes TimeService, a web service that runs in IIS on a Windows 2000 or Windows XP machine. There are also three client apps that consume the TimeService.ServerTime web service: TSWebClient is an ASP.NET client, TSWinClient is a WinForms client, and TS6Client is a VB6 client built with the Microsoft SOAP Toolkit 2.0. The client applications will run under Win2000, WinXP, WinNT SP6 or Win98. You can connect to a working version of the TimeService web service at my web site: http://www.vbnetexpert.com/vsm/timeservice/servertime.asmx. There's also a working version of the TSWebClient app at: http://www.vbnetexpert.com/vsm/timeservice/frmTime.aspx.

To load the sample code on your machine, you must have the .NET Framework Release version installed. For the TimeService sample, if your desired project directory is in the web server root directory, start VS.NET and create a new ASP.NET project in the with the name TimeService: http://localhost/TimeService. Delete the Service1.asmx file from the project. Shut down VS.NET, and unzip the TimeService.zip file into the TimeService directory. Restart VS.NET and open the TimeService project. Right-click on the ServerTime.asmx file and choose Set as Start Page from the pop-up menu. Run the project by pressing F5, and you'll see the default web service help page for the TimeService web service.

If you don't want TimeService to be in the web server root, start by creating a physical directory for the project on your machine (ex: c:\inetpub\wwwroot\vsm\TimeService\). In the Internet Services Manager, create a new Virtual Directory pointing to your new physical directory (ex: TimeService). In VS.NET, choose Create Project, click on the ASP.NET Web Service template, and select your new virtual directory in the Location field (replace WebApplication1 with TimeService). Click OK, and VS.NET creates the template project for you. Delete the Service1.asmx file from the project. Shut down VS.NET and unzip the sample TimeService project code into the physical directory pointed to by the TimeService virtual directory. Restart VS.NET and open the TimeService project. Right-click on the ServerTime.asmx file and choose Set as Start Page from the pop-up menu. Run the project by pressing F5, and you'll see the default web service help page for the TimeService web service. 

Follow the same procedure for the TSWebClient application - create an ASP.NET Web Application project in VS.NET and delete the default WebApplication1.aspx file. Shut down VS.NET, and unzip the TSWebClient zip file into the project directory. Restart VS.NET and open the TSWebClient project. To get the project to work, you may need to delete the TimeService item under Web References, then create a new Web Reference. DO this by right-clicking the TSWebClient project item and choosing Add Web Reference from the pop-up menu. Enter the URL to the TimeService web service in the Address line (ex: http://localhost/timeservice/servertime.asmx). Then rename the new localhost item to TimeService. If you instead want to run the TSWebClient against the sample web service on my website, enter its URL in the Add Web Reference dialog (http://www.vbnetexpert.com/vsm/timeservice/servertime.asmx) and rename the new web reference to TimeService.

For the TSWinClient, you can create the project directory anywhere you'd like. Unzip the contents of the TSWinClient.zip file into the directory, and double-click the TSWinClient.sln file to open the project in VS.NET. If the web service is located at: http://localhost/timeservice/servertime.asmx, the project should run without changes. If your web service directory is different from the above, or you want to run the project against the sample on my web site, then delete the TimeService web reference from the project. Then add a new Web Reference as described in the paragraphs above, and rename it TimeService.

For the TS6Client, you must first install the Microsoft SOAP Toolkit 2.0 on your development machine. You can find the toolkit for download at (make sure the entire URL goes into your browser's address line): http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/580/msdncompositedoc.xml
Unzip the TS6Client files into a directory, double-click the .vbp file to load the project, and type in the URL of your TimeService web service's WSDL (ex: http://localhost/TimeService/ServerTime.asmx?wsdl). If you want to use the sample web service on my web site, enter the URL to that WSDL location (http://www.vbnetexpert.com/vsm/TimeService/ServerTime.asmx?wsdl). Then run the project and click the Get Time button.
