Wsdl


WSDL completely describes Web services, the methods available, and the various ways of calling these methods. The exact details of this process won't really benefit you 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, and so on), and various bindings between these specifications. WSDL is understood by a variety of clients — not just .NET ones, but others such as Macromedia Flash, as mentioned in the introduction to this chapter.

Perhaps the most important part of a WSDL file is the type-definition section. This section uses XML schemas to describe the format for data exchange with the XML elements that can 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" encoding="utf-8"?> <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" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" ...other namespaces...> <wsdl: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:schema> </wsdl:types> ...other definitions... </definitions> 

These types are all that are required for the SOAP and HTTP requests and responses you 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 between 1 or 1 times, meaning that it must be included.

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

After this brief look at SOAP and WSDL it's time to move on to discuss how you create and consume Web services.




Professional C# 2005
Pro Visual C++ 2005 for C# Developers
ISBN: 1590596080
EAN: 2147483647
Year: 2005
Pages: 351
Authors: Dean C. Wills

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