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:
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:
- Click Start, and then click My
Computer.
- 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\ - In the Machine.config file, locate the <configuration> element.
- 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. - 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.