Discovering Web Services

   


Publish an XML Web Service : Enable static discovery.

Publish an XML Web Service: Publish XML Web Service definitions in the UDDI .

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 the messages that they accept and the services that 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

  • UDDI

  • WSDL

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 contains paths and other information for retrieving other 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 in order to use it.

For Visual Studio .NET projects, you won't ordinarily want to build a Disco document because 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 HOURGLASS, and a base class name of strings.asmx, you can retrieve static discovery information by navigating to http://HOURGLASS/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.

STEP BY STEP

4.5 Creating a Discovery Document

  1. Open the Web Service project that you created in Step by Step 4.2.

  2. Add a new Static Discovery File to the project. Name the new document StringProc.disco.

  3. 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> 
  4. In another Visual Studio .NET project, right-click the References node in Server Explorer and select Add Web Reference. Enter http:// YourServerName /StringProc/StringProc.disco to view the discovery file, as shown in Figure 4.11.

    Figure 4.11. Setting a Web reference through a static discovery file.

  5. 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 resource. UDDI registries are sites that contain information 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.

UDDI registries come in two formspublic 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.

NOTE

The UDDI Project The UDDI specification is being developed jointly by several industry partners , including Microsoft and IBM. For more information and a public directory, visit http://www.uddi.org.


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.

STEP BY STEP

4.6 Registering a Web Service with UDDI

  1. Open a browser window and navigate to http://test.uddi.microsoft.com/default.aspx . This opens the UDDI Test Site, shown in Figure 4.12. Of course, Microsoft redesigns this site regularly, so your screen might look a little different.

    Figure 4.12. The UDDI Test Registry.

  2. Click the Register link.

  3. Sign in using your Microsoft Passport. If you do not have a Microsoft Passport, follow the instructions to create one.

  4. 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.

  5. Click the Publish link.

  6. Click the Providers tab, and then click the Add Publisher button.

  7. Fill in your business details and click Publish to add your business to the UDDI registry.

  8. Return to the Administer page.

  9. Click the tModels link and then click the Add tModel button. A tModel is a description published to a UDDI registry.

  10. 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:// YourServerName /StringProc/Strings.asmx?WSDL , as the document location.

  11. After you have published your business and service details, you can use the Search link to locate your information in the UDDI Test Registry.

Using the Web Services Discovery Tool ( disco.exe )

When you set a Web reference inside of Visual Studio .NET, the software automatically handles the details of discovery for you. But you can also get into the details of the process yourself. One of the tools included in the .NET Framework SDK (and also in Visual Studio .NET) is the Web Services Discovery Tool, disco.exe . This is a command-line tool that will assist you in the discovery process, as seen in Step by Step 4.7.

STEP BY STEP

4.7 Using the Web Services Discovery Tool

  1. Select Start, Programs, Microsoft Visual Studio .NET, Visual Studio .NET Tools, Visual Studio .NET Command Prompt. This opens a command prompt window and sets up the environment so that you can use any of the command-line tools from the .NET Framework SDK.

  2. 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 base address of the Web service to use this tool.

  3. 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, the tool will also retrieve that document.

  4. Open the files in Visual Studio .NET to see the results of the discovery process.

  5. The results.discomap file is an XML file that shows you the name of the other file and the URL from which its contents were retrieved.

  6. The AirportWeather.wsdl file is an XML file that contains information on the interface of the Web service. This includes details of the messages, parameters, and objects with which you can interact. This file gives Visual Studio .NET the details it needs to enable you to use a Web service from your code.

REVIEW BREAK

  • 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.


   
Top


MCAD. MCSD Training Guide (Exam 70-310. Developing XML Web Services and Server Components with Visual Basic. NET and the. NET Framework)
MCAD/MCSD Training Guide (70-310): Developing XML Web Services and Server Components with Visual Basic(R) .NET and the .NET Framework
ISBN: 0789728206
EAN: 2147483647
Year: 2002
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net