Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to use static discovery and dynamic discovery in XML Web services with the .NET Framework


View products that this article applies to.

Summary

This step-by-step article describes how to use XML Web services static discovery and XML Web services dynamic discovery. You can use XML Web services discovery to locate and to interrogate XML Web services descriptions. XML Web services discovery is the first step that you do when you access an XML Web service. XML Web services discovery is a Microsoft-specific technology that you can use to locate the XML Web services in a particular directory on a particular server. There are three types of XML Web services discovery files. These XML Web services discovery files use the following extensions:
  • .disco
  • .vsdisco
  • .map

Use XML Web services static discovery

Create the XML Web services discovery file and then point the XML Web services discovery file to XML Web Services Description Language (WSDL). The XML Web services discovery file contains a root <disco> element. The root <disco> element contains one or more <contractRef> elements and one or more <discoveryRef> elements. The following URL contains the definition of the <contractRef> element and of the <discoveryRef> element:

http://schemas.xmlsoap.org/disco/scl/

In the following code sample, the <contractRef> tag references is the actual XML Web service URL that returns the WSDL. The <discoveryRef> element refers to another discovery document. The XML Web services static discovery file code is shown in the following code sample:
<?xml version="1.0" encoding="utf-8" ?>
<discovery xmlns="http://schemas.xmlsoap.org/disco/">
<discoveryRef ref="/Folder/Default.disco"/>
<contractRef ref="http://localhost/WebService3/Service1.asmx?WSDL"
             docRef="Service.htm"
             xmlns="http://schemas.xmlsoap.org/disco/scl/"/>
<schemaRef ref="Schema.xsd"
           xmlns="http://schemas.xmlsoap.org/disco/schema/"/>
</discovery>
You can access the XML Web services static discovery file by using an .asmx file.

Discuss XML Web services dynamic discovery

The XML Web services dynamic discovery file returns XML code that contains references to WSDL and references to the XML Web services discovery file when you access the URL. If a client computer requests an XML Web services dynamic discovery file (.vsdisco), the Microsoft .NET Framework analyzes the folder that contains the XML Web services dynamic discovery file. The .NET Framework then generates XML code that contains the references to all XML Web services in that folder and in its subfolders. To enhance security, you can use the XML Web services dynamic discovery file (.vsdisco) to specify that the .NET Framework must not search certain folders while the XML code is generated.

Enable XML Web services dynamic discovery

To enable XML Web services dynamic discovery, follow these steps:
  1. Click Start, and then click My Computer.
  2. In the following folder, open the Machine.config file:

    %WINDIR%\Framework\v1.0.3705\

    Note In this step, %WINDIR% is the placeholder for the absolute path of your Microsoft Windows directory.

    In the following folder, open the Machine.config file by using Notepad if you are using Microsoft .NET Framework 1.1:

    %WINDIR%\Framework\v1.1.4322\
  3. In the Machine.config file, locate the <configuration> element.
  4. Add the following XML code between the <configuration> element and the </configuration> element:
      <system.web>
         <httpHandlers>
           <add verb="*" path="*.vsdisco"
               type="System.Web.Services.Discovery.DiscoveryRequestHandler,
                     System.Web.Services, Version=1.0.3300.0,
                     Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
               validate="false"/>
         </httpHandlers>
       </system.web>
    
    Note Make sure that the type attribute is on one line.
  5. On the File menu, click Save All to save the file, and then close the file.

Understand the implications for XML Web services when you enable dynamic discovery

When you enable dynamic discovery, you must be aware of the following implications:
  • If you enable the XML Web services dynamic discovery option, you can access all the XML Web services that exist on the Web server for the URL that you requested. Therefore, you must be cautious when you enable dynamic discovery. You may unintentionally expose sensitive data.
  • The XML Web services dynamic discovery file generates more performance overhead than the XML Web services static discovery file. This issue occurs because you must always perform a search operation to access the XML Web services dynamic discovery file.

↑ Back to the top


References

For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
309013� HOW TO: Create and test an XML Web service in Visual Basic .NET
301273� HOW TO: Write a simple Web service by using Visual Basic .NET
307303� INFO: Troubleshooting Add Web Reference issues
For additional information about enabling discovery for an XML Web service, visit the following Microsoft Developer Network (MSDN) Web site:For additional information about deploying XML Web services, visit the following MSDN Web site:

↑ Back to the top


Keywords: KB833382, kbhowtomaster, kbconfig, kbappdev, kbdiscovery, kbuser, kbclient, kbremoting

↑ Back to the top

Article Info
Article ID : 833382
Revision : 6
Created on : 4/29/2007
Published on : 4/29/2007
Exists online : False
Views : 601