WSDL

 
Chapter 15 - Web Services
bySimon Robinsonet al.
Wrox Press 2002
  

WSDL completely describes Web Services, the methods available, and the various ways of calling these methods . Again, the exact details of this won't really benefit us that much, but a general understanding is useful.

WSDL is another fully XML-compliant syntax, and specifies Web Services by the methods available, the types used by these methods, the formats of request and response messages sent to and from methods via various protocols (pure SOAP, HTTP GET, etc.), and various bindings between the above.

Perhaps the most important part of a WSDL file is the type-definition section. This uses XML schemas to describe the format for data exchange via the XML elements that may be used, and their relationships.

For example, the Web Service method used as an example in the last section:

   int DoSomething(string stringParam, int intParam)   

would have types declared for the request as follows :

   <?xml version="1.0" ?>     <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"     xmlns:s="http://www.w3.org/2001/XMLSchema"     ...other namespaces...>     <types>     <s:schema elementFormDefault="qualified"     targetNamespace="http://tempuri.org/">     <s:element name="DoSomething">     <s:complexType>     <s:sequence>     <s:element minOccurs="0" maxOccurs="1" name="stringParam"     type="s:string" />     <s:element minOccurs="1" maxOccurs="1" name="intParam"     type="s:int" />     </s:sequence>     </s:complexType>     </s:element>     <s:element name="DoSomethingResponse">     <s:complexType>     <s:sequence>     <s:element minOccurs="1" maxOccurs="1" name="DoSomethingResult"     type="s:int" />     </s:sequence>     </s:complexType>     </s:element>     <s:element name="int" type="s:int" />     </s:schema>     </types>     ...other definitions...     </definitions>   

These types are all that are required for the SOAP and HTTP requests and responses we saw earlier, and are bound to these operations later in the file. All the types are specified using standard XML schema syntax, for example:

 <s:element name="DoSomethingResponse">             <s:complexType>                <s:sequence>                   <s:element minOccurs="1" maxOccurs="1" name="DoSomethingResult"                              type="s:int" />                 </s:sequence>             </s:complexType>          </s:element> 

This specifies that an element called DoSomethingResponse has a child element called DoSomethingResult that contains an integer. This integer must occur 0 or 1 times, meaning that it may be omitted.

If we have access to the WSDL for a Web Service then we can use it. As we will see shortly, this isn't that difficult to do.

Now we've had a brief look at SOAP and WSDL it's time to move on to look at how we create and consume Web Services.

  


Professional C#. 2nd Edition
Performance Consulting: A Practical Guide for HR and Learning Professionals
ISBN: 1576754359
EAN: 2147483647
Year: 2002
Pages: 244

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