The Web Services Description Language



The Web Services Description Language

At this point, you probably have a pretty good idea of what kind of information should go into WSDL. .NET and most major Web service implementations now support WSDL, which is currently in version 1.1.

The major goals of WSDL were extensibility, abstraction, and structure. Let's examine each of these goals and then dissect a WSDL document to see how it accomplishes them.

Extensibility

One of the most interesting reasons to use elements instead of attributes when designing an XML schema is how much more expressive and extensible elements can be. You can extend an attribute to contain extra data. However, you can state in your schema that the element may contain new and interesting attributes and elements. Listing 10.1 shows a simple XML schema.

: Using Attributes in an XML Schema
<xs:schema
     targetNamespace="http://keithba.com/Car"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns="http://keithba.com/Car"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified">
     <xs:complexType name="CarType">
          <xs:sequence>
               <xs:element name="Tires" type="xs:integer"/>
               <xs:element name="Color" type="xs:string"/>
               <xs:any namespace="##other"/>
          </xs:sequence>
     </xs:complexType>
</xs:schema>

This schema in Listing 10.1 describes a document that looks like this:

<Car xmlns="http://keithba.com/Car"> 
     <Tires>4</Tires>
     <Color>Blue</Color>
</Car>

By allowing the use of extra elements and attributes, someone could extend this document, as shown in Listing 10.2.

: Adding Description Through Elements and Attributes
<xs:schema
     targetNamespace="http://keithba.com/CarExtensions"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns="http://keithba.com/CarExtensions"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified">
     <xs:complexType name="StereoType">
          <xs:sequence>
               <xs:element name="Make" type="xs:string"/>
               <xs:element name="Model" type="xs:string"/>
               <xs:element name="Decibels" type="xs:float"/>
          </xs:sequence>
     </xs:complexType>
</xs:schema>

Notice that the extensions in Listing 10.2 are in a new namespace. This is usually a very good idea, although not a requirement. Now, we can have a document like this:

<Car xmlns="http://keithba.com/Car"> 
     <Tires>4</Tires>
     <Color>Blue</Color>
     <Stereo xmlns="http://keithba.com/CarExtensions">
          <Make>BlahPunk</Make>
          <Model>BlueLine</Model>
          <Decibels>40</Decibels>
      </Stereo>
</Car>

WSDL uses this very powerful extension mechanism in its <binding> section. This allows for the creation of new standards that can extend the power of a WSDL document. For example, BPEL (Business Process Execution Language for Web Services) takes advantage of these extensions to describe the orchestration between operations and services.

WSDL also provides extensibility by not mandating XML Schemas or SOAP. In fact, a WSDL document can describe any kind of Web service, such as a Web-DAV or MIME (Multipurpose Internet Mail Extension) service, over any transport. The <binding> section of WSDL allows for any type of binding, such as SOAP over HTTP, via the extension mechanism just discussed. But it also defines extensions for several popular bindings.

Abstraction

WSDL doesn't follow the concrete pattern you would expect of a Web service description. Instead, it abstractly defines terms such as data types and message operations. Only later in the <binding> and <service> elements sections does it get its hands dirty enough to discuss concrete information such as SOAPAction and HTTP endpoint.

In other words, WSDL allows for a very high level of abstraction. My feeling is that the abstraction away from providing the endpoint is the most important aspect. I often refer to the information in a WSDL document up to and including the <binding> section as the abstract pieces, even though the <binding> section does contain concrete information, at least when compared with the other sections.

As people build more and more standard Web services, this abstraction capability will play a greater role. It's easy to imagine a scenario in which a shipping industry consortium, for example, gets together and defines a standard set of operations for using SOAP over HTTP to send shipping information. WSDL makes it easy to capture all of this information in a natural manner. Implementations then can import the appropriate WSDL, and extend authoring of the <service> section with their particular endpoint.

Structure

Web services are based on XML, which is a highly structured meta language. Web services in general are involved in highly structured messages and message patterns. WSDL provides a way to model this complexity of message operations and the patterns of messages and their operations.