Discovering Web Services
Publish an XML Web Service
One of the problems with Web services is simply finding them. Because Web services aren't installed on your computer, you need some way to determine what messages they accept and what services they provide. The usual term for this process is discovery, which encompasses both finding Web services and determining their interfaces. You should know about three protocols in this area:
Disco and UDDI
Disco is a Microsoft standard for the creation of discovery documents. A Disco document is kept at a standard location on a Web services server and it contains paths and other information for retrieving useful information, such as the WSDL file that describes a service. This document is used for static discovery. That is, a potential user of your Web service must know the location of the Disco document to use it.
For Visual Studio .NET projects, you ordinarily won't want to build a Disco document. Such projects are designed to generate discovery information from their base URL. For example, if your Web service is named StringProc and is stored on a server with the name INFINITY, and a base class name of Strings.asmx, you can retrieve static discovery information by navigating to http://INFINITY/StringProc/Strings.asmx?wsdl.
Sometimes, though, you'll want to generate a completely static discovery document that does not require processing to create. Step-by-Step 4.5 shows you how.
|
4.5 Creating a Discovery Document
Open the StringProc Web Service project that you created in Step-by-Step 4.2. Right-click the StringProc Web service project and select Add, Add New Item from the context menu. In the Add New Item dialog box select the Web Project Items Categories and the Static Discovery File template. Name the new document StringProc.disco and click Open. Enter this code in the new file:
<?xml version="1.0" encoding="utf-8" ?>
<discovery xmlns="http://schemas.xmlsoap.org/disco/">
<contractRef ref="Strings.asmx?WSDL"
xmlns="http://schemas.xmlsoap.org/disco/scl/" />
</discovery>
In another Visual Studio .NET project, right-click the References node in Server Explorer and select Add Web Reference. Enter http://localhost/StringProc/StringProc.disco (substituting your own Web server name for localhost, if the Web server is not on your local machine) to view the discovery file, as shown in Figure.

Click on the View Contract link to see the WSDL for the Web service.
|
UDDI (Universal Description, Discovery, and Integration) is a method for finding services by referring to a central directory. These can be Web services, URLs for information, or any other online resources. UDDI registries are sites that contain information that is available via UDDI; you can search such a registry to find information about Web services. UDDI thus provides dynamic discovery, allowing you to find Web services even when you do not know their location in advance.
NOTE
The UDDI Project
The UDDI specification is developed jointly by several industry partners, including Microsoft and IBM. For more information and a public directory, visit www.uddi.org.
UDDI registries come in two forms: public and private. A public UDDI registry is available to all comers via the Internet and serves as a central repository of information about Web and other services for businesses. A private UDDI registry follows the same specifications as a public UDDI registry but is located on an intranet for the use of workers at one particular enterprise.
To add your own services to a UDDI registry, you must use the tools provided by that particular registry. Step-by-Step 4.6 shows you how to add your Web service to the Microsoft Test UDDI Registry.
|
4.6 Registering a Web service with UDDI
Open a browser window and navigate to http://test.uddi.microsoft.com/default.aspx. This opens the UDDI Test Registry, as shown in Figure.

Click the Register link. Sign in using your Microsoft Passport. If you do not already have a Microsoft Passport, follow the instructions to create one. Fill in the registration form to create a UDDI publisher account. Follow the directions to respond to the validation email if you do not share your Passport email address. Click the Administer link. Click the Add a New Business link. Fill in your business details and click Publish to add your business to the UDDI registry. Return to the Administer page. Click the Add a New tModel link. Fill in the details of your Web service. You can provide the URL of a static discovery document, or an ASP.NET WSDL URL such as http://infinity/StringProc/Strings.asmx?WSDL (substituting your own Web server name for infinity), as the document location.
After you have published your business and service details, you can use the Search link to locate your information in the UDDI Test Registry.
|
NOTE
Use a Test UDDI Registry For Testing
To test your Web service without impacting other UDDI users you should use a test UDDI Registry such as test.uddi.microsoft.com instead of a production UDDI Registry such as uddi.microsoft.com.
Using the Web Services Discovery Tool (disco.exe)
When you set a Web reference inside Visual Studio .NET, the software handles the details of discovery automatically for you. But you can also get into the details of the process yourself. One of the tools included in the .NET Framework Software Development Kit (SDK) (and also in Visual Studio .NET) is the Web Services Discovery tool, disco.exe. This command-line tool assists you in the discovery process, as seen in Step-by-Step 4.7.
|
4.7 Using the Web Services Discovery Tool
Select Start, Programs, Microsoft Visual Studio .NET, Visual Studio .NET Tools, Visual Studio .NET Command Prompt. This opens a command prompt window and sets the environment up so that you can use any of the command-line tools from the .NET Framework SDK. Enter the following command to discover the details of the Airport Weather Web Service:
disco http://live.capescience.com/wsdl/AirportWeather.wsdl
As you can see, you need to know the Web service's base address to use this tool. The tool contacts the Web service and (in this case) creates two files of results: AirportWeather.wsdl and results.discomap. If the Web service includes a static discovery document (.disco file), the tool also retrieves that document.
NOTE
Discovery File (.disco)—
The disco.exe also retrieves a discovery document, if the Web service includes a static discovery document (.disco file). The discovery file is an XML file containing useful URLs. These include the URL for the WSDL file describing the service, the URL for the documentation of the service, and the URL to which SOAP messages should be sent.
Dynamic Discovery
Visual Studio .NET also creates a dynamic discovery document (.vsdisco file) for ASP.NET Web service applications. The dynamic discovery document is an XML-based file that contains links to resources that provide discovery information for a Web service. Open these files in Visual Studio .NET to see the results of the discovery process.
The results.discomap file is an XML file that shows you the name of the other file (AirportWeather.wsdl) and the URL from which its contents were retrieved.
The AirportWeather.wsdl file is an XML file that contains information about the Web service's interface. This includes details of the messages, parameters, and objects with which you can interact. It's this file that gives Visual Studio .NET the details that it needs to let you use a Web service from your code.
|
Disco is Microsoft's standard format for discovery documents, which contain information on Web services. UDDI, the Universal Description, Discovery, and Integration protocol, is a multi-vendor standard for discovering online resources, including Web services. The Web Services Discovery tool, disco.exe, can retrieve discovery information from a server that exposes a Web service.
|
|