Sunday, November 28, 2004

Web services discovery

If you want to use a webservice in your .Net applications, you have to know the URL to add a webreference to it. (If you encounter a problem, take a look at Troubleshooting add web reference problems) You can set individual web references to .asmx files, but if your application uses many services, this is not very handy. To solve this Microsoft provides discovery information. Microsoft provides discovery information in 2 ways, statically with disco files and dynamically with vsdisco files. With dynamic discovery the discovery document is generated at runtime. A .disco file contains markup that specifies references to a web service's WSDL file and other DISCO documents.

When a .vsdisco file is requested, the .NET framework analyzes the directory in which the .vsdisco file is located, as well as that directory's subdirectories and returns markup that contains references to all web services in that directory and the directory's subdirectories (It is however possible to exclude some directories from being searched).
A vsdisco file would look this
<?xml version="1.0" ?>
<dynamicDiscovery xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">
<exclude path="_vti_cnf" />
<exclude path="_vti_pvt" />
<exclude path="_vti_log" />
<exclude path="_vti_script" />
<exclude path="_vti_txt" />
</dynamicDiscovery>


Dynamic discovery is however disabled by default. With the .Net framework you had to remove the comments from the following lines in your machine.config. With the .Net framework 1.1 these lines are removed from the machine.config so you have to add them yourself.
<!--<add verb="*" path="*.vsdisco"
type="System.Web.Services.Discovery.DiscoveryRequestHandler,
System.Web.Services, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>-->


As you can see dynamic discovery is accomplished in ASP.NET by mapping the file name extension VSDISCO
to an HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files. For more info about http handlers definitely take a look at Using HTTP Modules and Handlers to Create Pluggable ASP.NET Components

No comments:

Post a Comment