You are on page 1of 12

What's New in WSDL 2.

0
By Arulazi Dhesiaseelan
May 20, 2004

The W3C's Web Services Description Working Group, part of the Web Services Activity, has
defined a language for describing web services and the possible ways to interact with them. The
WG published its WSDL 2.0 working drafts on 26 March 2004. This is a significant milestone in
the progress of WSDL. In this article, I discuss the changes that were made to the WSDL 1.1
specification and other major improvements to the service description language.

W3C WSDL 2.0 Working Drafts

W3C has published the following core working drafts as part of its working group deliverables:

• Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language
• Web Services Description Language (WSDL) Version 2.0 Part 2: Message Patterns
• Web Services Description Language (WSDL) Version 1.2 Part 3: Bindings

Other related working drafts include requirements and usage scenarios.

• Web Services Description Requirements


• Web Services Description Usage Scenarios

The W3C XML Schema definition for WSDL 2.0 specification can be found at
http://www.w3.org/2003/11/wsdl/.

The editor's copies of these documents provide updated information about the progress of these
specifications.

Changes from the WSDL 1.1 Specification

WSDL 1.2 was renamed WSDL 2.0 because of its substantial differences from WSDL 1.1. Some
of these changes include:

• Adding further semantics to the description language. This is one of the reasons for
making targetNamespace a required attribute of the definitions element in WSDL
2.0.
• Removal of message constructs. These are specified using the XML schema type system
in the types element.
• No support for operator overloading.
• PortTypes renamed to interfaces. Support for interface inheritance is achieved by
using the extends attribute in the interface element.
• Ports renamed to endpoints.

WSDL 2.0 Conceptual Model


The description of a web service can be modeled in two parts. In the abstract part, WSDL
describes a web service in terms of messages it sends and receives through a type system,
typically W3C XML Schema. Message exchange patterns define the sequence and cardinality of
messages. An operation associates message exchange patterns with one or more messages. An
interface groups these operations in a transport and wire independent manner.

In the concrete part of the description, bindings specify the transport and wire format for
interfaces. A service endpoint associates network address with a binding. Finally, a service
groups the endpoints that implement a common interface. Figure 1 shows the conceptual WSDL
component model.

Figure 1: WSDL Conceptual model

WSDL Components

WSDL provides a set of components and their associated properties for describing web services.
Listing 2 shows the skeleton of the WSDL 2.0 description. The following section gives a brief
overview about each of these components.

<definitions targetNamespace="xs:anyURI">
<documentation /> ?
[<import /> | <include /> ] *
<types /> ?
[<interface /> | <binding /> | <service /> ] *
</definitions>

Listing 2: WSDL 2.0 Skeleton

Definitions
The definitions element is the root of any WSDL document. It serves as a container which
holds all the necessary information about the service and its attributes. Figure 2 shows the
schema for the definitions element. The targetNamespace attribute of the definitions
element is a required attribute of type anyURI. The namespace can directly or indirectly define
the semantics of the WSDL. Also, the definitions element can have other optional attributes
which correspond to various namespaces that may be used with in the WSDL document.

Figure 2: definitions schema

Include

The include element helps to modularize the web service descriptions so that separation of
various service definition components from the same target namespace can be allowed to exist in
another WSDL document which can be used or shared across web service descriptions. The
location attribute is mandatory and specifies the location of these WSDL documents. The
actual value of the target namespace of the included WSDL must match the target namespace of
the definitions element in the including WSDL. Figure 3 shows the XML schema for the
include element.
Figure 3: include schema

Import

The concept behind the import element is very similar to that of include element, except that
the imported WSDL can be in different target namespaces. The namespace attribute for the
import element is mandatory while the location attribute is optional. Figure 4 shows the XML
schema for the import element.

Figure 4: import schema

Types

The types element defines the data types used by the exchanged messages. WSDL uses W3C
XML Schema as its preferred schema language. It also supports other systems such as DTDs and
RELAX NG. Schemas may be used by importing or embedding within the types element of the
WSDL document. Importing can be done using the construct xs:import while embedding uses
the construct xs:schema. The imported or embedded schema components are available to
WSDL for reference by QName. Figure 5 shows the XML schema for the types element.
Figure 5: types schema

Interface

An interface element encloses a named set of abstract operations and the abstract messages. It
can optionally extend one or more other interfaces. Interfaces are referred to by QName in other
components such as bindings. The interface operation element has name and pattern as
required attributes, while style is an optional attribute. Figure 6 shows the schema for the
interface element. Features defines functionalities associated with the message exchanges
between communicating parties, which might include reliability, security, correlation, and
routing. Property is used to control the behavior of a feature. It has a set of possible and
permissible values specified by references to a schema description. These values can be shared
among features.

Figure 6: interface schema

Binding

The binding element defines the underlying transport and wire format for messages. Each
binding in the WSDL references to an interface. All operations defined within the interface must
be bound in the binding. An endpoint in the service component references a binding. Both
endpoints and bindings are modeled to support flexibility and location transparency. Multiple
endpoints with different network address can still share the same protocol binding. WSDL 2.0
Bindings specification defines binding extensions for protocols and message formats such as
SOAP, HTTP and MIME. Figure 7 shows the XML schema for the binding element.

Figure 7: binding schema

Service

A service element describes a set of endpoints which refer to a single network address for a
binding. All other protocol specific information is contained in the binding. Service can be
referred by QName. service element has a name and interface which are required attributes.
Figure 8 shows the XML schema for the service element.

Figure 8: service schema

WSDL Message Exchange Patterns

Message exchange patterns define the sequence and cardinality of messages within an operation.
Several types of message patterns are defined in the “Part 2: Message Patterns†of the
WSDL 2.0 specifications. WSDL message exchange patterns uses fault generation rules to
indicate the occurrence of faults. Message exchange may be terminated if fault generation
happens regardless of standard rule sets. The following standard rule set outlines the behavior of
fault generation.

• Fault Replaces Messages


• Message Triggers Fault
• No Faults
Figure 9 shows the various message exchange patterns with their fault reference rules.

Figure 9: WSDL Message Exchange Patterns

Stock Quote Service Description in WSDL 1.1 & WSDL 2.0

In this section, you can have a preview of a simple stock quote service which is described using
WSDL 1.1 and WSDL 2.0. Listing 2 shows the XML schema types that are used in the
describing stock quote service. Listing 3 and 4 shows the stock quote service interface definition
in WSDL 1.1 and WSDL 2.0 respectively. Listing 5 and 6 shows the stock quote service
implementation definition in WSDL 1.1 and WSDL 2.0 respectively.

http://example.com/stockquote/stockquoteV11.xsd

<?xml version="1.0"?>
<schema targetNamespace="http://example.com/stockquote/schemas"

xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name="TradePriceRequest">
<complexType>
<all>

<element name="tickerSymbol" type="string"/>


</all>
</complexType>
</element>
<element name="TradePrice">
<complexType>
<all>
<element name="price" type="float"/>
</all>
</complexType>
</element>
</schema>

http://example.com/stockquote/stockquoteV20.xsd

<?xml version="1.0"?>
<schema targetNamespace="http://example.com/stockquote/schemas"

xmlns="http://www.w3.org/2001/XMLSchema">
<element name="TradePriceRequest">
<complexType>
<all>

<element name="tickerSymbol" type="string"/>


</all>
</complexType>
</element>
<element name="TradePrice">
<complexType>
<all>

<element name="price" type="float"/>


</all>
</complexType>
</element>
</schema>

Listing 2: XML Schema definition for Stock Quote Service

http://example.com/stockquote/stockquoteV11.wsdl

<?xml version="1.0"?>
<definitions name="StockQuote"
targetNamespace="http://example.com/stockquote/definitions"

xmlns:tns="http://example.com/stockquote/definitions"

xmlns:xsd1="http://example.com/stockquote/schemas"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns="http://schemas.xmlsoap.org/wsdl/">

<import namespace="http://example.com/stockquote/schemas"

location="http://example.com/stockquote/stockquoteV11.xsd"/>

<message name="GetLastTradePriceInput">
<part name="body" element="xsd1:TradePriceRequest"/>
</message>

<message name="GetLastTradePriceOutput">

<part name="body" element="xsd1:TradePrice"/>


</message>

<portType name="StockQuotePortType">

<operation name="GetLastTradePrice">

<input message="tns:GetLastTradePriceInput"/>

<output message="tns:GetLastTradePriceOutput"/>
</operation>
</portType>
</definitions>

Listing 3: WSDL 1.1 Interface definition for Stock Quote Service

http://example.com/stockquote/stockquoteV20.wsdl

<?xml version="1.0"?>
<definitions name="StockQuote"
targetNamespace="http://example.com/stockquote/definitions"

xmlns:tns="http://example.com/stockquote/definitions"

xmlns:xsd1="http://example.com/stockquote/schemas"

xmlns:soap="http://www.w3.org/2003/11/wsdl/soap12"

xmlns="http://www.w3.org/2003/11/wsdl">

<import namespace="http://example.com/stockquote/schemas"

location="http://example.com/stockquote/stockquoteV20.xsd"/>

<types>

<schema targetNamespace="http://example.com/stockquote/definitions">

<element name="GetLastTradePriceInput" type="xsd1:TradePriceRequest"/>

<element name="GetLastTradePriceOutput" type="xsd1:TradePrice"/>


</schema>
</types>

<interface name="StockQuoteInterface">

<operation name="GetLastTradePrice"
pattern="http://www.w3.org/2003/11/wsdl/in-out">
<input message="tns:GetLastTradePriceInput"/>

<output message="tns:GetLastTradePriceOutput"/>
</operation>
</interface>
</definitions>

Listing 4: WSDL 2.0 Interface definition for Stock Quote Service

http://example.com/stockquote/stockquoteserviceV11.wsdl

<?xml version="1.0"?>
<definitions name="StockQuote"
targetNamespace="http://example.com/stockquote/service"

xmlns:tns="http://example.com/stockquote/service"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:defs="http://example.com/stockquote/definitions"

xmlns="http://schemas.xmlsoap.org/wsdl/">

<import namespace="http://example.com/stockquote/definitions"

location="http://example.com/stockquote/stockquoteV11.wsdl"/>

<binding name="StockQuoteSoapBinding" type="defs:StockQuotePortType">

<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="GetLastTradePrice">

<soap:operation soapAction="http://example.com/GetLastTradePrice"/>
<input>

<soap:body use="literal"/>
</input>
<output>

<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="StockQuoteService">

<documentation>My first service</documentation>

<port name="StockQuotePort" binding="tns:StockQuoteBinding">

<soap:address location="http://example.com/stockquote"/>
</port>
</service>
</definitions>

Listing 5: WSDL 1.1 Implementation definition for Stock Quote Service

http://example.com/stockquote/stockquoteserviceV20.wsdl

<?xml version="1.0"?>
<definitions name="StockQuote"
targetNamespace="http://example.com/stockquote/service"

xmlns:tns="http://example.com/stockquote/service"

xmlns:wsoap="http://www.w3.org/2003/11/wsdl/soap12"

xmlns:defs="http://example.com/stockquote/definitions"

xmlns="http://www.w3.org/2003/11/wsdl">

<import namespace="http://example.com/stockquote/definitions"

location="http://example.com/stockquote/stockquoteV12.wsdl"/>

<binding name="StockQuoteSoapBinding" interface="defs:StockQuoteInterface">

<wsoap:binding protocol="http://www.w3.org/2003/11/wsdl/http"/>

<operation name="GetLastTradePrice">

<wsoap:operation soapAction="http://example.com/GetLastTradePrice"/>
<input>
<wsoap:body/>
</input>
<output>
<wsoap:body/>
</output>
</operation>
</binding>
<service name="StockQuoteService">

<documentation>My stock quote service</documentation>

<endpoint name="StockQuoteEndPoint" binding="tns:StockQuoteSoapBinding">

<wsoap:address location="http://example.com/stockquote"/>
</endpoint>
</service>
</definitions>

Listing 6: WSDL 2.0 Implementation definition for Stock Quote Service


Summary

In this article I have explained some details of the working draft WSDL 2.0 specifications.
Discussions are happening in this working group for adding more features to the existing
specification in order to provide a highly flexible and robust language for describing web
services. Some of the features include web service references, versioning, attributes, and
compositors. In addition to these new features, further refinements are made to the existing
specification. The developer community is anticipating a more stable version of WSDL 2.0
specification in the near future.