There is a process wherein a discovery process can be performed on Web Services. The process is known as discovery (sometimes XML discovery), and its target is always a URL. A client process can find what Web Services exist on a server, what its capabilities are, and how to interact with it.

Given the URL to a server with Web Services, or the URL to a Web Service itself, files can be retrieved that are related to the extant Web Services. These files might include service descriptions (which use the Web Service Description Language, or WSDL), XSD schemas, or discovery documents (usually in the form of .disco files). Given the returned information, a proxy stub that is capable of accessing the Web Service can be created.

Let's try it out on one of the Web Services that are on First, though, you need to be able to run disco.exe from a command prompt on your system. The file is usually contained in the c:\Program Files\Microsoft Visual Studio .NET\Bin directory (along with a lot of other useful Framework utilities). You can type in the full path each time you run the program (not a pleasant thought), copy the utilities to a directory that's easier to type (also not an optimal option), or add c:\Program Files\Microsoft Visual Studio .NET\Bin to your system's path. I chose the latter, and I did this by selecting the System icon from Control Panel. From the Advanced tab, I clicked on the Environmental Variables. It was then easy to access the Path variable and add the additional directory. Then, when running the Framework utilities, you won't need to type in the full path. You could also use the Visual Studio .NET command prompt.

When you type in disco from the command prompt, you'll see the options that are available. For this example, we'll just enter the URL that we want to perform discovery on, and the files will be saved to the current directory by default.

There's a Web Service (which we'll talk about later in this chapter) that can be found at the URL If we add the parameter WSDL to the URL request, the disco program will generate a WSDL document on the local hard drive, along with a .discomap file.

From a command line, enter the following:


The program will query the Web Service and create two files in the current directory. One will be named results.discomap and the other will be named service1.wsdl. The results.discomap file can be seen in Listing 14.7.

Listing 14.7 The results.discomap File Resulting from Performing Discovery on the PharmFromNDC Web Service
 <?xml version="1.0" encoding="utf-8"?> <DiscoveryClientResultsFile xmlns:xsd=""     xmlns:xsi="">   <Results>     <DiscoveryClientResult       referenceType="System.Web.Services.Discovery.ContractReference"        url=""        filename="service1.wsdl" />   </Results> </DiscoveryClientResultsFile> 

Looking at the .discomap file, you can see that it is XML. The XML version is included, along with the location of this version's specifications, on Between the <Results> tags are the .NET Framework Namespace that's used for Web Service discovery, the URL from which the discovery was obtained, and the local file name that contains the WSDL contact information.

The .wsdl file is where you can find out information about the Web Service: its methods, properties, and use. Listing 14.8 contains the service1.wsdl file.

Listing 14.8 The service1.wsdl File Resulting from Performing Discovery on the PharmFromNDC Web Service
 <?xml version="1.0" encoding="utf-8"?> <definitions xmlns:http="" xmlns:soap="" xmlns:s="" xmlns:s0="" xmlns:soapenc="" xmlns:tm="" xmlns:mime="" targetNamespace="" xmlns="">   <types>     <s:schema elementFormDefault="qualified"       targetNamespace="">       <s:element name="GetPharm">         <s:complexType>           <s:sequence>             <s:element minOccurs="0" maxOccurs="1" name="strNDC" type="s: string" />           </s:sequence>         </s:complexType>       </s:element>       <s:element name="GetPharmResponse">         <s:complexType>           <s:sequence>             <s:element minOccurs="0" maxOccurs="1" name="GetPharmResult" type="s:string" />           </s:sequence>         </s:complexType>       </s:element>       <s:element name="string" nillable="true" type="s:string" />     </s:schema>   </types>   <message name="GetPharmSoapIn">     <part name="parameters" element="s0:GetPharm" />   </message>   <message name="GetPharmSoapOut">     <part name="parameters" element="s0:GetPharmResponse" />   </message>   <message name="GetPharmHttpGetIn">     <part name="strNDC" type="s:string" />   </message>   <message name="GetPharmHttpGetOut">     <part name="Body" element="s0:string" />   </message>   <message name="GetPharmHttpPostIn">     <part name="strNDC" type="s:string" />   </message>   <message name="GetPharmHttpPostOut">     <part name="Body" element="s0:string" />   </message>   <portType name="Service1Soap">     <operation name="GetPharm">       <input message="s0:GetPharmSoapIn" />       <output message="s0:GetPharmSoapOut" />     </operation>   </portType>   <portType name="Service1HttpGet">     <operation name="GetPharm">       <input message="s0:GetPharmHttpGetIn" />       <output message="s0:GetPharmHttpGetOut" />     </operation>   </portType>   <portType name="Service1HttpPost">     <operation name="GetPharm">       <input message="s0:GetPharmHttpPostIn" />       <output message="s0:GetPharmHttpPostOut" />     </operation>   </portType>   <binding name="Service1Soap" type="s0:Service1Soap">     <soap:binding transport="" style="document" />     <operation name="GetPharm">       <soap:operation soapAction="" style= "document" />       <input>         <soap:body use="literal" />       </input>       <output>         <soap:body use="literal" />       </output>     </operation>   </binding>   <binding name="Service1HttpGet" type="s0:Service1HttpGet">     <http:binding verb="GET" />     <operation name="GetPharm">       <http:operation location="/GetPharm" />       <input>         <http:urlEncoded />       </input>       <output>         <mime:mimeXml part="Body" />       </output>     </operation>   </binding>   <binding name="Service1HttpPost" type="s0:Service1HttpPost">     <http:binding verb="POST" />     <operation name="GetPharm">       <http:operation location="/GetPharm" />       <input>         <mime:content type="application/x-www-form-urlencoded" />       </input>       <output>         <mime:mimeXml part="Body" />       </output>     </operation>   </binding>   <service name="Service1">     <port name="Service1Soap" binding="s0:Service1Soap">       <soap:address location="" />     </port>     <port name="Service1HttpGet" binding="s0:Service1HttpGet">       <http:address location="" />     </port>     <port name="Service1HttpPost" binding="s0:Service1HttpPost">       <http:address location="" />     </port>   </service> </definitions> 

ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ASP. NET Solutions - 24 Case Studies. Best Practices for Developers
ISBN: 321159659
Year: 2003
Pages: 175 © 2008-2017.
If you may any questions please contact us: