This document is a companion to the WSDL 2.0
specification (
This primer is only intended to be a starting point toward use of WSDL 2.0, and hence does not describe every feature of the language. Users are expected to consult the WSDL 2.0 specification if they wish to make use of more sophisticated features or techniques.
Finally, this primer is
This is a
Comments on this document are to be sent to the public
A
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document has been produced under the
$Date: 2005/08/02 20:36:17 $
This primer assumes that the reader has the following prerequisite knowledge:
familiarity with XML ( some familiarity with XML Schema ( familiarity with basic Web services concepts such as Web service, client, and the purpose and function of a Web service description. (For an explanation of basic Web services concepts, see
Section 2 starts with a hypothetical use case involving a hotel reservation service. It proceeds step-by-step through the development of a simple example WSDL 2.0 document that describes this service: The The The The types
element describes the kinds of messages that the service will send and receive. interface
element describes binding
element describes service
element describes
After presenting the example, it moves on to introduce the WSDL 2.0 infoset, schema, and component model. Then it provides more detailed coverage on defining message types, interfaces, bindings, and services.
Section 3 explains the WSDL 2.0 importing mechanisms in great details.
Section 4 talks about WSDL 2.0 extensibility and various predefined extensions.
Section 5 covers various topics that may fall outside the scope of WSDL 2.0, but shall provide useful background and best practice guidances that may be useful when authoring a WSDL 2.0 document or implementing the WSDL 2.0 specification.
This document uses several XML namespaces, some of which are defined by standards, and some are application-specific. Namespace names of the general form
Following the convention for XML syntax sumary in The syntax appears as an XML instance, but the values indicate the data types instead of values. Characters are appended to elements and attributes as follows: "?" (0 or 1), "*" (0 or more), "+" (1 or more). Elements names ending in "…" indicate that elements/attributes irrelevant to the context are being omitted.
This section introduces the basic concepts used in WSDL 2.0 through the description of a hypothetical hotel reservation service. We start with a simple scenario, and later add more requirements to illustrate how more advanced WSDL 2.0 features may be used.
Hotel GreatH (a fictional hotel)) is located in a remote island. It has been relying on fax and phone to provide room reservations. Even though the facilities and prices at GreatH are better than what its competitor offers, GreatH notices that its competitor is getting more customers than GreatH. After research, GreatH realizes that this is because the competitor offers a Web service that permits travel agent reservation systems to reserve rooms directly over the Internet. GreatH then hires us to build a reservation Web service with the following functionality: checkAvailability
message and return a checkAvailabilityResponse
or invalidDataFault
message.makeReservation
message and return a makeReservationResponse
or invalidCreditCardFault
message.
The next several sections proceed step-by-step through the process of developing a WSDL 2.0 document that describes the desired Web service. However, for those who can't wait to see a complete example, here is the WSDL 2.0 document that we'll be creating.
Before writing our WSDL 2.0 document, we need to decide on a
The value of the WSDL 2.0 target namespace must be an absolute URI. Furthermore, it should be dereferenceable to a WSDL 2.0 document that describes the Web service that the WSDL 2.0 target namespace is used to describe. For example, the GreatH owners should make the WSDL 2.0 document available from this URI. (And if a WSDL 2.0 description is split into multiple documents, then the WSDL 2.0 target namespace should resolve to a master document that includes all the WSDL 2.0 documents needed for that service description.) However, there is no absolute requirement for this URI to be dereferenceable, so a WSDL 2.0 processor must not depend on it being dereferenceable.
This recommendation may sound circular, but bear in mind that the client might have obtained the WSDL 2.0 document from anywhere -- not necessarily an authoritative source. But by dereferencing the WSDL 2.0 target namespace URI, a user should be able to obtain an authoritative version. Since GreatH will be the owner of the service, the WSDL 2.0 target namespace URI should refer to a location on the GreatH Web site or otherwise within its control.
Once we have decided on a WSDL 2.0 target namespace URI, we can begin our WSDL 2.0 document as the following empty shell.
Every WSDL 2.0 document has a
This is the XML namespace for WSDL 2.0 itself. We assign it as the default namespace for this example by not defining a prefix for it. In other words, any unprefixed elements in this example are expected to be WSDL 2.0 elements (such as the This defines the WSDL 2.0 target namespace that we have chosen for the GreatH reservation service, as described above. Note that this is not an actual XML namespace declaration. Rather, it is a WSDL 2.0 attribute whose purpose is This is an actual XML namespace declaration for use in our GreatH service description. Note that this is the same URI that was specified above as the value of the description
element as its top-most element. This merely acts as a container for the rest of the WSDL 2.0 document, and is used to declare namespaces that will be used throughout the document.description
element).
tns:
prefix in QNames, to refer to the WSDL 2.0 target namespace of the GreatH service. (For more on QNames see
Now we can start describing the GreatH service.
We know that the GreatH service will be sending and receiving messages, so a good starting point in describing the service is to define the message types that the service will use. We'll use XML Schema to do so, because WSDL 2.0 processors are likely to support XML Schema at a minimum. However, WSDL 2.0 does not prohibit the use of some other schema definition language.
WSDL 2.0 allows message types to be defined directly within the WSDL 2.0 document, inside the types
element, which is a child of the description
element. (Later we'll see how we can provide the type definitions in a separate document, using XML Schema's import
mechanism.) The following schema defines checkAvailability
, checkAvailabilityResponse
and invalidDataError
message types that we'll need.
In WSDL 2.0, all normal and fault message types must be defined as single
We've added another namespace declaration. The ghns
namespace prefix will allow us (later, when defining an interface) to reference the XML Schema target namespace that we define for our message types. Thus, the URI we specify must be the same as the URI that we define as the target namespace of our XML Schema types (below) --
This is the XML Schema target namespace that we've created for use by the GreatH reservation service. The checkAvailability
, checkAvailabilityResponse
and invalidDataError
element names will be associated with this XML Schema target namespace.
These are the message types that we'll use. Note that these are defined to be XML
Although we have defined several types, we have not yet indicated which ones are to be used as message types for a Web service. We'll do that in the next section.
WSDL 2.0 enables one to separate the description of a Web service's abstract functionality from the concrete details of how and where that functionality is offered. This separation facilitates different levels of reusability and distribution of work in the lifecycle of a Web service and the WSDL 2.0 document that describes it.
A WSDL 2.0 interface
defines the abstract interface of a Web service as a set of abstract
For the GreatH service, we will (initially) define an interface containing a single operation, opCheckAvailability
, using the checkAvailability
and checkAvailabilityResponse
message types that we defined in the types
section. We'll use the
In addition to the normal input and output messages, we also need to specify the fault message that we wish to use in the event of an error. WSDL 2.0 permits fault messages to be declared within the interface
element in order to facilitate reuse of faults across operations. If a fault occurs, it terminates whatever message sequence was indicated by the message exchange pattern of the operation.
Let's add these to our WSDL 2.0 document.
Interfaces are declared directly inside the description
element. In this example, we are declaring only one interface, but in general a WSDL 2.0 document may declare more than one interface. Thus, each interface must be given a name that is unique within the set of interfaces defined in this WSDL 2.0 target namespace. Interface names are tokens that must not contain a space or colon (":").
The name
attribute defines a name for this fault. The name is required so that when an operation is defined, it can reference the desired fault by name. Fault names must be unique within an interface.
The element
attribute specifies the schema type of the fault message, as previously defined in the types
section.
The name
attribute defines a name for this operation, so that it can be referenced later when bindings are defined. Operation names must also be unique within an interface. (WSDL 2.0 uses separate symbol spaces for operation and fault names, so operation name "foo" is distinct from fault name "foo".)
This line specifies that this operation will use the
This line indicates that the XML schema defining the input message of this operation follows a set of rules as specified in
This line indicates that this operation will not obligate the client in any way, i.e., the client can safely invoke this operation without fear that it may be incurring an obligation (such as agreeing to buy something). This is further explained in
The input
element specifies an input message. Even though we have already specified which message exchange pattern the operation will use, a message exchange pattern represents a template for a message sequence, and in theory could consist of multiple input and/or output messages. Thus we must also indicate which potential input message in the pattern this particular input message represents. This is the purpose of the messageLabel
attribute. Since the
This specifies the message type for this input message, as defined previously in the types
section.
This is similar to defining an input message.
This associates an output fault with this operation. Faults are declared a little differently than normal messages. The ref
attribute refers to the name of a previously defined fault in this interface -- not a message schema type directly. Since message exchange patterns could in general involve a sequence of several messages, a fault could potentially occur at various points within the message sequence. Because one may wish to associate a different fault with each permitted point in the sequence, the messageLabel
is used to indicate the desired point for this particular fault. It does so indirectly by specifying the message that will either trigger this fault or that this fault will replace, depending on the pattern. (Some patterns use a
Now that we've defined the abstract interface for the GreatH service, we're ready to define a binding for it.
Although we have specified
In the general case, binding details for each operation
and fault are specified using
operation
and
fault
elements inside a
binding
element, as shown in the example below. However, in some
cases it is possible to use defaulting rules to supply
the information. The WSDL 2.0 SOAP binding extension, for example,
defines some defaulting rules for operations. (See
In order to accommodate new kinds of message formats and
transmission protocols, bindings are defined using
extensions to the WSDL 2.0 language, via WSDL 2.0's open
content model. (See
For the GreatH service, we will use SOAP 1.2 as our concrete message format and HTTP as our underlying transmission protocol, as shown below.
We've added two more namespace declarations. This one is the namespace for the SOAP 1.2 binding extension that is defined in WSDL 2.0 Part 3 wsoap:
are constructs defined there.
This namespace is defined by the SOAP 1.2 specification itself. The SOAP 1.2 specification defines certain terms within this namespace to unambiguously identify particular concepts. Thus, we will use the soap:
prefix when we need to refer to one of those terms.
Bindings are declared directly inside the description
element. The
This is the name of the interface whose message format and transmission protocols we are specifying. As discussed in tns:
prefix, which refers to the previously defined WSDL 2.0 target namespace for this WSDL 2.0 document. In this case it may seem silly to have to specify the tns:
prefix, but in
This specifies what kind of concrete message format to use, in this case SOAP 1.2.
This attribute is specific to WSDL 2.0's SOAP binding extension (thus it uses the wsoap:
prefix). It specifies the underlying transmission protocol that should be used, in this case HTTP.
This is not defining a new operation; rather, it is referencing the
previously defined
opCheckAvailability
operation in order to specify binding details for it. This
element can be omitted if defaulting rules are instead used to
supply the necessary information. (See the SOAP binding extension in
WSDL 2.0 Part 2
This attribute is also specific to WSDL 2.0's SOAP binding extension. It specifies the SOAP message exchange pattern (MEP) that will be used to implement the abstract WSDL 2.0 message exchange pattern (opCheckAvailability
operation was defined.
When HTTP is used as the underlying transport protocol (as in this example) the wsoap:mep
attribute also controls whether GET or POST will be used as the underlying HTTP method. In this case, the use of wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"
causes GET to be used by default. See also
As with a binding operation, this is not declaring a new fault; rather, it is referencing a fault (invalidDataFault
) that was previously defined in the opCheckAvailability
interface, in order to specify binding details for it.
This attribute is also specific to WSDL 2.0's SOAP binding extension. This specifies the SOAP 1.2 fault code that will cause this fault message to be sent. If desired, a list of subcodes can also be specified using the optional
Now that our binding has specified service
element.
A WSDL 2.0
Here is a definition for our GreatH service.
This defines a name for this service, which must be unique among service names in the WSDL 2.0 target namespace. The name attribute is required. It allows URIs to be created that identify components in WSDL 2.0 description. (See
This specifies the name of the previously defined interface that these service endpoints will support.
This defines an endpoint for the service, and a name for this endpoint, which must be unique within this service.
This specifies the name of the previously defined binding to be used by this endpoint.
This specifies the physical address at which this service can be accessed using the binding specified by the
That's it! Well, almost.
As we have seen, a WSDL 2.0 document is inherently only a
The documentation
element allows the WSDL 2.0 author to include some human-readable documentation inside a WSDL 2.0 document. It is also a convenient place to reference any additional external documentation that a client developer may need in order to use the service. It can appear in a number of places in a WSDL 2.0 document (see
This element is optional, but a good idea to include. It can contain arbitrary mixed content.
The most important thing to include is a pointer to any additional documentation that a client developer would need in order to use the service.
This completes our presentation of the GreatH example. In the following sections, we will move on to look into more details of various aspects of WSDL 2.0 specification.
In computer science theory, a language consists of a (possibly infinite) set of sentences, and each sentence is a finite string of literal symbols or characters. A language specification must therefore define the set sentences in that language, and, to be useful, it should also indicate the meaning of each sentence. Indeed, this is the purpose of the WSDL 2.0 specification.
However, instead of defining WSDL 2.0 in terms of literal symbols or characters, to avoid dependency on any particular character encoding, WSDL 2.0 is defined in terms of the description
element information item (in the XML Infoset) that conforms to the WSDL 2.0 specification. In other words, a sentence in the WSDL 2.0 language is a description
element information item that obeys the additional constraints spelled out in the WSDL 2.0 specification.
Since an XML Infoset can be created from more than one physical document, a WSDL 2.0 document does not necessarily correspond to a single import
and include
mechanisms, a WSDL 2.0 document may reference other WSDL 2.0 documents to facilitate convenient organization or reuse. In such cases, the meaning of the including or importing document as a whole will depend (in part) on the meaning of the included or imported document.
The XML Infoset uses terms like "element information item" and "attribute information item". Unfortunately, those terms are rather lengthy to repeat often. Thus, for convenience, this primer often uses the terms "element" and "attribute" instead, as a shorthand. It should be understood, however, that since WSDL 2.0 is based on the XML Infoset, we really mean "element information item" and "attribute information item", respectively.
The following diagram gives an overview of the XML Infoset for a WSDL 2.0 document.
The WSDL 2.0 specification supplies a
This section gives an example of how WSDL 2.0 specification constrains the WSDL 2.0 schema about the ordering of top WSDL 2.0 elements.
Although the WSDL 2.0 schema does not indicate the required ordering of elements, the WSDL 2.0 specification (WSDL 2.0 Part 1 description
element should be ordered. Thus, the order of the WSDL 2.0 elements matters, in spite of what the WSDL 2.0 schema says.
The following is a pseudo-content model of description
.
In other words, the children elements of the
description
element should be ordered as follows:
An optional
then comes zero or more elements from among the following, in any order:
extensions
An optional
Zero or more elements from among the following, in any order:
extensions.
Note the term "extension" is used above as a convenient way to refer to namespace-qualified extension elements. The namespace name of such extension elements must not be
The WSDL 2.0 Infoset model above illustrates the required structure of a WSDL 2.0 document, using the XML Infoset. However, the WSDL 2.0 language also imposes many semantic constraints over and above structural conformance to this XML Infoset. In order to precisely describe these constraints, and as an aid in precisely defining the meaning of each WSDL 2.0 document, the WSDL 2.0 specification defines a
In general, the WSDL 2.0 component model parallels the structure of the required XML Infoset illustrated above. For example, the description
, interface
, binding
, service
, and endpoint
element information items, respectively. Since WSDL 2.0 relies heavily on the component model to convey the meaning of the constructs in the WSDL 2.0 language, you can think of the Description component as representing the meaning of the description
element information item, and hence, it represents the meaning of the WSDL 2.0 document as a whole.
Furthermore, each of these components has service
element information item, so the Service component has an {endpoints} property whose value is a set of Endpoint components corresponding to the endpoint
element information item children of that service
element information item. (Whew!).
The WSDL 2.0 component model is particularly helpful in defining
the meaning of
In contrast, the
After processing any
We will cover a lot more about how to use WSDL 2.0 import and include in
The WSDL 2.0 types
element provides a mechanism for enclosing message schemas in a WSDL 2.0 document. Because WSDL 2.0 directly supports schemas written in XML Schema
There are two ways to indicate XML Schema message definitions using the types
element.
One way is to inline schema definitions within xs:schema
elements that are children of types
, as we have already seen. The other way is to use xs:import
directly under types
. It is perfectly reasonable to use both ways in one WSDL 2.0 document.
A WSDL 2.0
description
may only refer to XML Schema components that are either
imported nor inlined into that WSDL 2.0
description
. In other words, the use of
xs:import
and/or
xs:schema
is a necessary condition for making XML Schema
components available to a WSDL 2.0 Description
component.
The following XML syntax for the types
element illustrates the use of xs:import
and xs:schema
:
We have already seen an example of using inlined schema definitions in section
When XML Schema is inlined directly in a WSDL 2.0 document, it uses the existing top-level xs:schema
element defined by XML Schema types
element.
The schema components defined in the inlined schema are then available to
WSDL 2.0 for reference by QName (see WSDL 2.0 Part 1
Although WSDL 2.0 provides a wsdl:import
mechanism (described in the next section),
an inlined XML schema may also use XML Schema's native xs:import
and xs:include
elements to refer to schemas either in separate files or inlined in the same
WSDL 2.0 document. However, components inlined using xs:import
have different visibility from those
inlined using xs:include
: xs:include
d components are available to WSDL 2.0 for reference by QName, but xs:import
ed components are not.
There are many cases where one would prefer importing schema definitions from separate schema files instead of
inlining them directly under the types
element. One reason is reusability of the schemas. Although WSDL 2.0 provides a wsdl:import
mechanism,
type and element declarations inlined in a WSDL 2.0 document are NOT automatically made available to the importing document, even though other WSDL 2.0 components (such as Interfaces, Bindings, etc.) do become available. Therefore, if one wishes to share schema documents across several WSDL 2.0 documents, they should instead be placed in separate XML Schema documents and imported into each WSDL 2.0 document using xs:import
directly under types
.
Within the
Here is an example of importing a schema. Assuming the message types in
So far we have briefly covered both WSDL import/include and schema import/include. The following table summarizes the similarities and differences
between the WSDL 2.0 and XML Schema
Mechanism | Object | Meaning |
---|---|---|
wsdl:import | WSDL 2.0 Namespace | Declare that WSDL 2.0 components refer to WSDL 2.0 components from a DIFFERENT targetNamespace. |
wsdl:include | WSDL 2.0 Document | Merge Interface, Binding and Service components from another WSDL 2.0 document that has the SAME targetNamespace. |
xs:import | XML Schema Namespace | Declare that XML Schema components refer to XML Schema components from a DIFFERENT targetNamespace. |
xs:include | XML Schema Document | Merge XML Schema components from another XML Schema document that has the SAME targetNamespace. |
We previously mentioned that a WSDL 2.0 interface is basically a set of operations. However, there are some additional capabilities that we have not yet covered. First, let's review the syntax for the interface
element.
Below is the XML syntax summary of the interface
element, simplified by omitting optional <documentation>
elements and <feature>
and <property>
extension elements:
The interface
element has two optional attributes:
The optional
First, an inheritance loop (or infinite recursion) is prohibited: the interfaces that a given interface extends must NOT themselves extend that interface either directly or indirectly.
Second, we must explain what happens when operations
from two different interfaces have the same target
namespace and operation name. There are two cases:
either the component models of the operations are
the same, or they are different. If the component
models are the same (per the component comparison
algorithm defined in WSDL 2.0 Part 1
Finally, since faults can
also be defined as children of the
interface
element (as described in the following sections),
the same name-collision rules apply to those
constructs.
Let's say the GreatH hotel wants to maintain a standard message log operation for all received messages. It wants this operation to be reusable across the whole reservation system, so each service will send out, for potential use of a logging service,
the content of each message it receives together with a timestamp and the originator of the message. One way to meet such requirement is to define the log operation in an interface which can be inherited by other interfaces. Assuming a messageLog
element is already defined in the ghns namespace with the required content, the inheritance use case is illustrated in the following example. As a result of the inheritance, the reservationInterface
now contains two operations: opCheckAvailability
and opLogMessage
Now let's have a look at the element children of interface
, beginning with fault
.
The fault
element is used to declare faults that may occur during execution of operations of an interface. They are declared directly under interface
, and referenced from operations where they apply, in order to permit reuse across multiple operations.
Faults are very similar to messages and can be viewed as a special kind of message. Both faults and messages may carry a payload that is normally described by an element declaration. However, WSDL 2.0 treats faults and messages slightly differently. The messages of an operation directly refer to their element declaration, however the faults of an operation indirectly refer to their element declaration via a fault element that is defined on the interface.
The reason for defining faults at the interface level is to allow their reuse across multiple operations. This design is especially beneficial when bindings are defined, since in binding extensions like SOAP there is additional information that is associated with faults. In the case of SOAP, faults have codes and subcodes in addition to a payload. By defining faults at the interface level, common codes and subcodes can be associated with them, thereby ensuring consistency across all operations that use the faults
The
types
section. Please note that when other type systems
are used to define the schema for a fault message,
additional attributes may need to be defined via
WSDL 2.0's attribute extension mechanism to allow
the schema to be associated with the fault.
As shown earlier, the operation
element is used to indicate an operation supported by the containing interface. It associates message schemas with a message exchange pattern (MEP), in order to abstractly describe a simple interaction with a Web service.
An operation
has two required attributes and one optional attribute:
A required
A required operation
. MEPs are further explained in
An optional operation
. It is an error if a particular style is indicated, but the associated rules are not followed.
RPC Style. The RPC style is selected when the
IRI Style. The IRI style is selected when the
The Multipart style. The Multipart style is selected when the
You can find more details of these WSDL 2.0 predefined styles. Section style
.
Note that
An operation should be marked safe (by using the
The default value of this attribute is false. If it is false or is not set, then no assertion is made about the safety of the operation; thus the operation may or may not be safe.
An operation
will also have input
, output
,infault
, and/or outfault
element children that specify the ordinary and fault message types to be used by that operation. The MEP specified by the pattern
attribute determines which of these elements should be included, since each MEP has placeholders for the message types involved in its pattern.
Since operations were already discussed in
The
input
and
output
elements is optional. It is not necessary to
explicitly set the
messageLabel
when the MEP in use is one of the eight MEPs
predefined in WSDL 2.0 Part 2
The
The message content is any
single element.
There is no message content,
i.e., the message payload is
empty.
The message content is described by a non-XML type system.
Extension attributes specify the type.
input
and
output
elements is used to specify the message content
schema (aka payload schema) when the content
model is defined using XML Schema. As we have
seen already, it can specify the QName of an
element schema that was defined in the
types
section. However, alternatively it can specify
one of the following tokens:
element
attribute is also optional. If it is not specified, then the message content is described by a non-XML type system.
Note that there are situations that the information conveyed in the element
attribute is not sufficient for a service implementation to uniquely identify an incoming message and dispatch it to an appropriate operation. In such situations, additional means may be required to aid identifying an incoming message. See
When infault
and/or outfault
occur multiple times within an operation
, they define alternative fault messages.
WSDL 2.0 message exchange patterns (MEPs) are used to define the sequence and cardinality of the abstract messages in an operation. By design, WSDL 2.0 MEPs are abstract. First of all, they abstract out specific message types. MEPs identify placeholders for messages, and placeholders are associated with specific message types when an operation is defined, which includes specifying which MEP to use for that operation. Secondly, unless explicitly stated otherwise, MEPs also abstract out binding-specific information like timing between messages, whether the pattern is synchronous or asynchronous, and whether the messages are sent over a single or multiple channels.
It's worth pointing out that WSDL 2.0 MEPs do not exhaustively describe the set of messages that may be exchanged between a service and other nodes. By some prior agreement, another node and/or the service may send other messages (to each other or to other nodes) that are not described by the MEP. For instance, even though an MEP may define a single message sent from a service to one other node, a service defined by that MEP may multicast that message to other nodes. To maximize reuse, WSDL 2.0 message exchange patterns identify a minimal contract between other parties and Web Services, and contain only information that is relevant to both the Web service and the client that engages that service.
A total of eight MEPs are defined in
For the eight MEPs defined by WSDL 2.0, some of them are variations of others based on how faults may be generated. For example, the In-Only pattern ("http://www.w3.org/2005/08/wsdl/in-only") consists of exactly one message received by a service from some other node. No fault can be generated. As a variation of In-Only, Robust In-Only pattern ("http://www.w3.org/2005/08/wsdl/robust-in-only") also consists of exactly one message received by a service, but in this case faults can be triggered by the message and must be delivered to the originator of the message. If there is no path to this node, the fault must be discarded. For details about the common fault generation models used by the eight WSDL 2.0 MEPs, see
Depending on how the first message in the MEP is initiated, the eight WSDL 2.0 MEPs may be grouped into two groups: in-bound MEPs, for which the service receives the first message in the exchange, and out-bound MEPs, for which the service sends out the first message in the exchange. (Such grouping is not provided in the WSDL 2.0 specification and is presented here only for the purpose of easy reference in this primer).
A frequently asked question about out-bound MEPs is how a service knows where to send the message. Services using out-bound MEPs are typically part of large scale integration systems that rely on mapping and routing facilities. In such systems, out-bound MEPs are useful for specifying the functionality of a service abstractly, including its requirements for potential customers, while endpoint address information can be provided at deployment or runtime by the underlying integration infrastructure. For example, the GreatH hotel reservation system may require that every time a customer interacts with the system to check availability, data about the customer must be logged by a CRM system. At design time, it's unknown which particular CRM system would be used together with the reservation system. To address this requirement, we may change the "reservationInterface" in logInquiry
operation advertises to potential service clients that customer data will be made available by the reservation service at run time. When the reservation service is deployed to GreatH's IT landscape, appropriate configuration time and run time infrastructure will help determine which CRM system will get the customer data and log it appropriately. It's worth noting that in addition to being used by a CRM system for customer management purpose, the same data may also be used by a system performance analysis tool for different purpose. Providing an out-bound operation in the reservation service enables loose coupling and so improves the overall GreatH IT landscape's flexibility and scalability.
Although the eight MEPs defined in WSDL 2.0 Part 2
For more about defining new MEPs, see
Bindings are used to supply protocol and encoding details that specify binding
element uses a particular
Binding information must be supplied for every operation in the interface that is used in an endpoint. However, if the desired binding extension provides suitable defaulting rules, then the information will only need to be explicitly supplied at the interface level, and the defaulting rules will implicitly propagate the information to the operations of the interface. For example, see the
Since bindings are specified using extensions to the WSDL 2.0 language (i.e., binding extensions are not in the WSDL 2.0 namespace), the XML for expressing a binding will consist of a mixture of elements and attributes from WSDL 2.0 namespace and from the binding extension's namespace, using WSDL 2.0's open content model.
Here is a syntax summary for binding
, simplified by omitting optional documentation
, feature
and property
elements. Bear in mind that this syntax summary only shows the elements and attributes defined within the WSDL 2.0 namespace. When an actual binding is defined, elements and attributes from the namespace of the desired binding extension will also be intermingled as required by that particular binding extension.
The binding
syntax parallels the syntax of interface
: each interface construct has a binding counterpart. Despite this syntactic similarity, they are indeed different constructs, since they are in different symbol spaces and are designed for different purposes.
A binding can either be reusable (applicable to any
interface) or non-reusable (specified for a particular interface). Non-reusable bindings may be specified at the granularity of the interface (assuming the binding extension provides suitable defaulting rules), or on a per-operation basis if needed. A non-reusable binding was demonstrated in
To define a reusable binding, the binding
element simply omits the interface
attribute and omits specifying any
operation-specific and fault-specific binding details. Endpoints can later refer to a reusable binding in the same manner as for a non-reusable binding. Thus, a reusable binding becomes associated with a particular interface when it is referenced from an endpoint, because an endpoint is part of a service, and the service specifies a particular interface that it implements. Since a reusable binding does not specify an interface, reusable bindings cannot specify operation-specific details. Therefore, reusable bindings can only be defined using binding extensions that have suitable defaulting rules, such that the binding information only needs to be explicitly supplied at the interface level.
A binding fault
associates a concrete message format with an abstract fault
of an interface. It describes how faults that occur within a message exchange of an operation will be formatted, since the fault does not occur by itself. Rather, a fault occurs as part of a message
exchange specified by an interface operation
and its binding
counterpart, the binding operation
.
A binding fault
has one required interface
fault
for which binding information is being specified. Be aware that the value of faults
under a binding
must be unique. That is, one cannot define multiple bindings for the same interface fault within a given binding
.
A binding operation
describes a concrete binding of an interface
operation to a concrete message format. An interface
operation is uniquely identified by the WSDL 2.0 target namespace of the
interface and the name of the operation within that interface, via the required operation
. As with faults, for each operation
within a binding
, the value of the
The WSDL 2.0 SOAP Binding Extension (see WSDL 2.0 Part 2
An example using the WSDL 2.0 SOAP binding extension was already presented in Because the same binding extension is used for both SOAP 1.2 and SOAP 1.1, a The WSDL 2.0 SOAP binding extension defines a set of default rules, so that bindings can be specified at the interface level or at the operation level (or both), with the operation level taking precedence. However, it does not define default binding rules for faults. Thus, if a given interface defines any faults, then corresponding binding information must be explicitly provided for each such fault. If HTTP is used as the underlying protocol, then the binding can (and should) control whether each operation will use HTTP GET or POST. (See wsoap:version
attribute is provided to allow you to indicate which version of SOAP you want. If this attribute is not specified, it defaults to SOAP 1.2.
Here is an example that illustrates both a SOAP 1.2 binding (as seen before) and a SOAP 1.1 binding.
Most lines in this example is the same as previously explained in This is the namespace for terms defined within the SOAP 1.1 specification This line indicates that this binding uses SOAP 1.1 This line specifies that HTTP should be used as the underlying transmission protocol. See also Note that This line specifies the SOAP 1.1 fault code that will be used in transmitting invalidDataFault.wsoap:mep
is not applicable to SOAP 1.1 binding.
In addition to the WSDL 2.0 SOAP binding extension described above, WSDL 2.0 Part 2
The HTTP binding extension provides many features to control: Which HTTP operation will be used. (GET, PUT, POST, DELETE, and other HTTP operations are supported.) Input, output and fault serialization Transfer codings Authentication requirements Cookies HTTP over TLS (https)
As with the WSDL 2.0 SOAP binding extension, the HTTP binding extension also provides defaulting rules to permit binding information to be specified at the interface level and used by default for each operation in the affected interface, however, defaulting rules are not provided for binding faults.
Here is an example of using the HTTP binding extension to check hotel room availability at GreatH.
Most of this example is the same as previously explained in This defines the namespace prefix for elements and attributes defined by the WSDL 2.0 HTTP binding extension.
This declares the binding as being an HTTP binding.
The default method for operations in this interface will be HTTP GET. The Thus, in this example, each of the elements in the whttp:location
attribute specifies a pattern for serializing input message instance data into the path component of the request URI. The default binding rules for HTTP specify that the default input
serialization for GET is application/x-www-form-urlencoded
. Curly braces are used to specify the name of a schema type in the input message schema, which determines what input instance data will be inserted into the path component of the request URI. The curly brace-enclosed name will be replaced with instance data in constructing the path component. Remaining input instance data (not specified by whttp:location
) will either be serialized into the query string portion of the URI or into the message body, as follows: if a "/" is appended to a curly brace-enclosed type name, then any remaining input message instance data will be serialized into the message body. Otherwise it will be serialized into query parameters.tCheckAvailability
type will be serialized into the query parameters. A sample resulting URI would therefore be
http://greath.example.com/2004/checkAvailability/5-5-5?checkOutDate=6-6-5&roomType=foo
.
Here is an alternate example that appends "/" to the type name in order to serialize the remaining instance data into the message body:
This would instead serialize to a request URI such as: http://greath.example.com/2004/checkAvailability/bycheckInDate/5-5-5
. The rest of the message content would go to the HTTP message body.
When a binding using HTTP is specified for an operation, the WSDL 2.0 author must decide which HTTP method is appropriate to use -- usually a choice between GET and POST. In the context of the Web as a whole (rather than specifically Web services), the W3C Technical Architecture Group (TAG) has addressed the question of when it is appropriate to use GET, versus when to use POST, in a finding entitled
Recall that the concept of a safe operation was discussed in wsdlx:safe
attribute of an interface operation indicates that the abstract operation is safe, it does not automatically cause GET to be used at the HTTP level when the binding is specified. The choice of GET or POST is determined at the binding level:
If the WSDL 2.0 SOAP binding extension is used ( on the on the binding binding
element (to indicate the use of HTTP as the underlying protocol); andoperation
element, which causes GET to be used by default.
If the WSDL 2.0 HTTP binding extension is used directly ( on the on the binding on the bound binding
element; oroperation
element, which overrides whttp:methodDefault
if set on the binding
element; or interface operation
. When the above two items are not explicitly set, and when the bound interface operation is marked safe, the HTTP Binding will by default set the method to GET.
For example, in the GreatH interface definition shown in
In some circumstances WSDL authors may want to split up a Web service description into two or more documents. For example, if a description is getting long or is being developed by several authors, then it is convenient to divide it into several parts. Another very important case is when you expect parts of the description to be reused in several contexts. Clearly it is undesirable to cut and paste sections of one document into another, since that is error prone and leads to maintenance problems. More importantly, you may need to reuse components that belong to a wsdl:targetNamespace that is different than that of the document you are writing, in which case the rules of WSDL 2.0 prevent you from simply cutting and pasting them into your document.
To solve these problems,
WSDL 2.0 provides two mechanisms for modularizing Web service description documents: import
and include
.
This section discusses the import mechanism and describes some typical cases where it may be used.
The import
mechanism lets one refer to the definitions of Web service components that belong to other namespaces.
To illustrate this, consider the GreatH hotel reservation service. Suppose that the reservation service uses a
standard credit card validation service that is provided by a financial services company. Furthermore, suppose that
companies in the financial services industry decided that it would be useful to report errors in credit card validation
using a common set of faults, and have defined these faults in the following Web service description:
This example defines an interface, creditCardFaults
, that contains four faults, cancelledCreditCard
,
expiredCreditCard
, invalidCreditCardNumber
, and invalidExpirationDate
.
These components belong to the namespace http://finance.example.com/CreditCards/wsdl
.
Because these faults are defined in a different wsdl:targetNamespace than the one used by the GreatH Web service description, import must be used to make them available within the GreatH Web service description, as shown in the following example:
The hotel reservation service declares that it is using
components from another namespace via the
import
>
element. The import element has a required
namespace
attribute that specifies the other namespace, and an
optional
location
attribute that gives the processor a hint where to find
the description of the other namespace. The
reservation
interface extends the
creditCardFault
interface from the other namespace in order to make the
faults available in the reservation interface. Finally,
the
makeReservation
operation refers to the standard faults in its
outfault
elements.
Another typical situation for using imports is to define a standard interface that is to be implemented
by many services. For example, suppose the hotel industry decided that it was useful to have a standard interface for
making reservations. This interface would belong to some industry association namespace, e.g. http://hotels.example.com/reservations/wsdl
.
Each hotel that implemented the standard reservation service
would define a service in its own namespace, e.g. http://greath.example.com/2004/wsdl/resSvc
.
The description of each service would import the http://hotels.example.com/reservations/wsdl
namespace and refer to the
standard reservation interface in it.
WSDL 2.0 documents may contain one or more XML
schemas defined within the
wsdl:types
element. This section illustrates the correct way to
refer to these schemas, both from within the same
document and from other documents.
In this example, we consider some GreatH Hotel
Web services that retrieve and update
reservation details. The retrieval Web service
is defined in the
retrieveDetails.wsdl
WSDL 2.0 document, along with a schema for the
message format. The updating Web service is
defined in the
updateDetails.wsdl
WSDL 2.0 document which imports the first document
and refers to both WSDL 2.0 and schema definitions
contained in the imported document.
http://greath.example.com/2004/services/retrieveDetails
namespace. This WSDL 2.0 document also
contains an inline schema that describes the
reservation detail in the
http://greath.example.com/2004/schemas/reservationDetails
namespace. This schema is visible to the
retrieveDetailsInterface
interface definition which refers to it in the
retrieve
operation's output message.
http://greath.example.com/2004/services/updateDetails
namespace. The
updateDetailsInterface
interface extends the
retrieveDetailsInterface
interface. However, the
retrieveDetailsInterface
belongs to the
http://greath.example.com/2004/services/retrieveDetails
namespace, so updateDetails.wsdl
must import retrieveDetails.wsdl
to make that namespace visible.
The
updateDetailsInterface
interface also uses the
reservationDetails
element definition that is contained in the
inline schema of the imported
retrieveDetails.wsdl
document. However, this schema is not
automatically visible within the
updateDetails.wsdl
document. To make it visible, the
updateDetails.wsdl
document must import the namespace of the inline
schema within the
types
element using the XML schema
import
element.
In this example, the
schemaLocation
attribute of the
import
element has been omitted. The
schemaLocation
attribute is a hint to the WSDL 2.0 processor that tells it where to
look for the imported schema namespace.
However, the WSDL 2.0 processor has already
processed the
retrieveDetails.wsdl
document which contains the imported namespace
in an inline schema so it should not need any hints.
However, this behavior depends on
the implementation of the processor and so
cannot be relied on.
Although the WSDL 2.0 document may validly omit the
schemaLocation
attribute, it is a best practice to either provide a
reliable value for
it or move the inline schema into a separate
document, say
reservationDetails.xsd
, and directly import it in the
types
element of both
retrieveDetails.wsdl
and
updateDetails.wsdl
. In general, schemas that are expected to be
referenced from more than one WSDL 2.0 document
should be defined in a separate schema document
rather than be inlined.
A WSDL 2.0 document may define multiple inline
schemas in its
types
element. The two or more schemas may have the
same target namespace provided that they do not
define the same elements or types. It is an
error to define the same element or type more
than once, even if the definitions are
identical.
Each namespace of an inline schema becomes visible to the Web
service definitions. However, the namespaces are
not automatically visible to the other inline
schemas. Each inline schema must explicitly
import any other namespace it references. The
schemaLocation
attribute is not required in this case since the
WSDL 2.0 processor knows the location of each schema
by virtue of having processed the enclosing WSDL 2.0
document.
To illustrate this, consider
http://greath.example.com/2004/schemas/reservationItems
namespace
contains some elements for items that appear in
the reservation details. The
http://greath.example.com/2004/schemas/reservationDetails
namespace contains the
reservationDetails
element which refers to the item elements. The schema for the
http://greath.example.com/2004/schemas/reservationDetails
namespace contains an
import
element that imports the
http://greath.example.com/2004/schemas/reservationItems
namespace. No
schemaLocation
attribute is required for this import since the
schema is defined inline in the importing
document.
In the preceding examples, schemas were defined inline in WSDL 2.0 documents. This section discusses the correct way to specify a schemaLocation
attribute on a schema import
element to provide a processor with a hint for locating these schemas.
schemaLocation
attribute was omitted since the WSDL 2.0 processor was assumed to know how to locate the imported
schemas because they were part of the WSDL 2.0 documents being processed. The schemaLocation
attribute can be used to give the processor a URI reference
that explicitly locates the schemas. A URI reference is a URI plus an optional fragment identifier that indicates part of the resource. For schemas, the fragment should identify
the schema
element. The simplest way to accomplish this is to use the id
attribute, however XPointer (see
id
attribute. Both of the inline schemas have
id
attributes.
The id of the http://greath.example.com/2004/schemas/reservationItems
schema is items
and the id of the
http://greath.example.com/2004/schemas/reservationDetails
schema is details
.
The
import
element in the http://greath.example.com/2004/schemas/reservationDetails
schema uses the id of the
http://greath.example.com/2004/schemas/reservationItems
schema in the
schemaLocation
attribute, i.e. #items
.
WSDL 2.0 provides two extensibility mechanisms: an open content model, which allows XML elements and attributes from other (non-WSDL 2.0) XML namespaces to be interspersed in a WSDL 2.0 document; and
In either case, the URI that identifies the semantics of an extension should be dereferenceable to a document that describes the semantics of that extension. As of this writing, there is no generally accepted standard for what kind of document that should be. However, the
Extensions can either be required or optional.
An wsdl:required="false"
or the absence of the wsdl:required
attribute (because it defaults to false). Thus, a WSDL 2.0 processor, acting on behalf of the client, that encounters an unknown optional extension can safely ignore it and continue to process the WSDL 2.0 document. However, it is important to stress that optional extensions are only optional to the
A wsdl:required="true"
. If a WSDL 2.0 processor, acting on behalf of the client, encounters a required extension that it does not recognize or does not support, then it cannot safely continue to process the WSDL 2.0 document. In most practical cases, this is likely to mean that the processor will require manual intervention to deal with the extension. For example, a client developer might manually provide an implementation for the required extension to the WSDL 2.0 processor.
After a few successful trials of the reservation service, GreatH decides that it is time to make the makeReservation operation secure, so that sensitive credit-card information is not being sent across the public network in a snoopable fashion. We will do this using the WSDL 2.0 Features and Properties mechanisms
To facilitate presentation, this section will assume the existence of a hypothetical security feature named "http://features.example.com/2005/securityFeature
", which defines, in the abstract, the idea of message confidentiality. This feature has an associated property, named "http://features.example.com/2005/securityFeature/securityLevel
", which defines various safety levels (from 0 meaning clear text, all the way through 10, involving highly complex cryptographic algorithms with keys in the tens of thousands of bits). We also assume that a SOAP module (for more about SOAP module, see http://features.example.com/2005/modules/Security
", has been defined, which implements the security feature described above.
GreatH has chosen an abstract security feature which is standard in the fictitious hotels community, and has integrated both a SOAP module and a new secure HTTP binding into its infrastructure – both of which implement the security feature (the SOAP module does this inside the SOAP envelope using headers, and the secure binding does it at the transport layer). Now they'd like to advertise and control the usage of these extensions using WSDL 2.0.
The first step GreatH takes is to require the usage of the SOAP module in their normal SOAP/HTTP endpoint, which looks like this:
This syntax indicates that a SOAP Module is required by this endpoint. This means that anyone using this endpoint must both understand the specification that the module URI references, and must use that specification when communicating with the endpoint in question, which typically means including appropriate SOAP headers on transmitted messages.
If the "required" attribute was not present, or if it was set to "false
", then the <wsoap:module>
syntax would indicate optional the availability of the referenced module, rather than a requirement to engage it, as explained in
Since GreatH began the web service improvements, they have been talking to several travel agents. The possibility of making their simple hotel interface an industry standard amongst a consortium of hotels has come up, and as such they would like to enable specifying the requirement for the "makeReservation" operation to be secure at the interface level – in other words indicating that the operation must be secure, but without specifying exactly how that should concretely be achieved (to enable maximal reuse of the interface). The next example uses the WSDL 2.0 Feature element to indicate this.
This declaration indicates that understanding of, and compliance with, the specified security feature is required for all uses of the "makeReservation" operation. The security feature is
By definition, if you understand a SOAP module, you understand which (if any) abstract features it implements. Therefore, since the security module in this example is defined as an implementation of the abstract security feature, we know that the use of this module satisfies the requirement to implement the feature. Therefore users of the HTTP endpoint shown above (with the required SOAP module) will be able to make use of it. GreatH also defines a new endpoint:
The user will have a choice as to which of the endpoints, and therefore which binding, is to be used, but they both satisfy the abstract feature requirement specified in the interface.
Note that it is not necessary to declare the abstract feature in order to use/require the SOAP module, or in order to use/require the secure binding. Abstract feature declarations serve purely to indicate requirements which must be fulfilled by more concrete components such as modules or bindings. In other words, the abstract feature declaration allows components such as interfaces to be reused without caring exactly which SOAP modules or bindings satisfy the feature.
So far we've discussed how to indicate the availability or the "requiredness" of features and modules. Often it is not enough to indicate that a particular extension is available/required: you also need some way to control or parameterize aspects of its behavior. This is achieved by the use of WSDL 2.0 securityLevel
property should be 5 for the "makeReservation" operation, it would look like this:
The property
element specifies which property is to be set. By setting the value
element, a toolkit processing this WSDL 2.0 document is informed that the securityLevel property must be set to 5. The particular meanings of any such values are up to the implementations of the modules/bindings that use them. The property
element can be placed at many different levels in a WSDL 2.0 document (see "Property Composition Model" section in WSDL 2.0 Part 1
It is also possible to provide a
The security feature specification defines securityLevel as an integer with values between 1 and 10, each of which indicates, according to the spec, a progressively higher level of security. The GreatH service authors, having read the relevant specifications, have decided that any security level between 3 and 7 will be supported by their infrastructure. Levels less than 3 are deemed unsafe for GreatH's purposes, and levels greater than 7 require too much in the way of resources to make it worthwhile. We can express this in WSDL 2.0 as follows:
First we define, in the types
section, an XML Schema restriction type over integers with minimum and maximum values, per our discussion above. Then instead of using the value
element inside property
, we use constraint
and refer to the restriction type. This informs the implementation that the property must have the appropriate values. This information might be useful to a deployment user interface, for example, which might allow an administrator to set this value with a slider when deploying the service.
As we mentioned in
Following the wild success of its reservation service, GreatH discovered that it could radically increase tourist interest by supplying information on weather conditions, both to travel agents and to the general touring public. This produced a challenge for the service implementers: how could this information be supplied to interested parties without requiring knowledge of web service technology specifically, and of computers generally? At issue was the desire to provide asynchronous updates to unsophisticated customers without incurring onerous overheads for technical support.
The solution adopted was to create a standard mailing list, and to make available a small cross-platform web service client (actually, a subscriber) that could be installed on any computer with POP or IMAP access to a mailbox. The mailbox, once signed up for the mailing list, could either be processed as "dedicated" (to the GreatH weather service; travel agents did this) or as "general purpose" (in which case the application would only examine those emails that contained Subject headers associated with the service). This required development of a binding to email, which is out of scope for this example, but the resulting WSDL 2.0 was otherwise quite straightforward.
Note: the email binding in use here supports publish/subscribe, by supporting the robust-out-only MEP as well as the client/server style in-out used for subscribing and unsubscribing. Details of this binding would require a document as long as the primer, so play along.
Note: in the example, the messageLabels of all input and output elements have been elided, as they are not necessary to disambiguate (but note that the order of input and output elements is not significant).
Unfortunately, the service was soon highjacked for the purpose of annoyment. Repeatedly, hotels in less salubrious climes, and the victims of various natural climactic disasters (hurricanes, tornadoes) found themselves signed up to receive material full of incomprehensible pointy brackets. They complained to GreatH, who complained to their service designers.
Applying public key infrastructure to solving the problem was immediately rejected as too complex and too heavyweight. Analysis showed that the problem was simply to verify that the address requesting information actually wanted that information. Consequently, a new message exchange pattern was defined.
This pattern consists of two or more messages in order as follows:
A message:
indicated by a Message Label component whose
message label is
received from some node N1
A message:
indicated by a Message Label component whose message label is
sent to some node N2 (which
An optional message:
indicated by a Message Label component whose message label is
received from node N2
An optional message:
indicated by a Message Label component whose message label is
sent to node N2
This pattern uses the rule Message Triggers Fault.
An operation using this message exchange pattern has a pattern property with
the value
Once the MEP had been defined (and the email binding specification appropriately modified to indicate that this was a supported MEP), the service was redefined and redeployed. Only the changed operations are shown in the excerpt below.
Note: in the second example, the input and output examples are not in the sequence in which they occur in the pattern; this illustrates that the sequence is not significant. Note, however, that for this pattern, the messageLabel attribute is required on every input and output element.
Section style
attribute of an interface operation is used to indicate that the operation conforms to a particular pre-defined operation style, or set of constraints. Actually, if desired the style
attribute can hold a list of URIs, indicating that the operation simultaneously conforms to multiple styles.
Operation styles are named using URIs, in order to be unambiguous while still permitted new styles to be defined without requiring updates to the WSDL 2.0 language. WSDL 2.0 Part 2
The
A WSDL 2.0 document makes use of the RPC Style in an interface operation by first defining the operation in conformance with all of the RPC Style rules, and then setting that operation's style
attribute to include the URI that identifies the RPC Style, thus asserting that the operation does indeed conform to the RPC Style. These rules permit the input and output message schemas to map conveniently to inputs and outputs of a method signature. Roughly, input elements map to input parameters, output elements map to output parameters, and elements that appear both in the input and output message schemas map to input/output parameters. WSDL 2.0 Part 2 section "
The RPC Style also permits the full signature of the intended mapping to be indicated explicitly, using the wrpc:signature
attribute defined in WSDL 2.0 Part 2 section "
The example below illustrates how RPC Style may be used to designate a
signature. This example is a modified version of the GreatH reservation
service. In particular, the interface
and types
sections have been modified to specify and conform to the RPC Style.
Note that the interface operation's name "checkAvailability
", is the
same as the localPart of the input element's QName,
"tns:checkAvailability
". This is one of the requirements of the RPC Style. The name of the operation is
used as the name of the method in a language binding,
subject to further mapping restrictions specific to the target
programming language. In this case, the name of the method would be
"checkAvailability
".
The local children elements of the input element and output element
designate
the parameters and the return type for a method call. Note that the
elements checkInDate
, checkOutDate
are input parameters, however the
element roomType
is an in-out parameter, as it appears both as a local
element child of both input and output elements. This indicates that the reservation system may change the room type
requested based on availability.
The reservation service also returns a rate type for the reservation, such as "rack rate". The return value for the method is designated as the "rate" element.
Based on the value of the wrpc:signature
attribute, the method signature would be obtained following the order of the parameters. A sample
mapping is provided below for the Java(TM) language. This example was created using JAX RPC 1.1
Programming languages may further specify how faults are mapped to language constructs and their scopes, such as Exceptions, but they are not specific to RPC style.
Unlike WSDL 1.1 which defines a MIME binding for attachments support, WSDL 2.0 supports MIME attachments via the SOAP Message Transmission Optimization Mechanism (MTOM)
We will modify the CheckAvailability
operation of the GreatH Hotel Reservation Service (checkAvailabilityResponse
data structure to include binary data representing these two images, indicated by the xs:base64Binary
data type. Here is an example:
Note the use of the
xmime:expectedContentType
and
xmime:contentType
attributes to declare the expected media type of
the encoded data and to allow the client to
indicate the type at runtime, respectively. These
attributes are defined in
A checkAvailabilityResponse
message conforming to this schema might look like this:
While this (non-optimized) message satisfies the schema definition, a service may choose to allow or require that the binary data be sent in an optimized format using the Message Transmission and Optimization Mechanism (MTOM). The use of this feature by the WSDL 2.0 SOAP binding extension is indicated as follows:
The HTTP Message Transmission Optimization (MTOM) feature is engaged using the feature
element. Note that the attribute required="true"
on the feature declaration indicates that the message must be encoded using the HTTP Optimization feature. If the attribute were required="false"
(or this attribute were absent), it would indicate that the use of MTOM is optional for this service: the service accepts either MTOM-encoded messages, or the embedded base64Binary data directly in the SOAP Body, and the client is free to send either form of message.
The example above shows MTOM enabled for a specific message within an operation. Placing the feature declaration as a child of operation
would require (or enable if required="false"
) MTOM support for all the messages in that operation. Placing the feature declaration as a child of binding
would require (or enable if required="false"
) MTOM support for all the operations in that interface.
This section covers various topics that may fall outside the scope of WSDL 2.0, but shall provide useful background and best practice guidances that may be useful when authoring a WSDL 2.0 document or implementing the WSDL 2.0 specification.
It is desirable for a message recipient to have the capability to uniquely identify a message in order to handle it correctly. The capability of identifying a message is typically used for dispatching purposes within an implementation of a web service. Therefore, WSDL authors are recommended to take disambiguating of messages that are defined in a description into consideration when they develop descriptions of their services.
The context that a Web service may be deployed plays an important role in choosing an appropriate way to disambiguate and identify messages. In a typical deployment, an endpoint address may host a single service that is described by a WSDL service element. In this case, when XSD is used, assigning unique qualified names of global element declarations as inputs within the interface that describes the service would be sufficient to disambiguate the messages that are received. However, when endpoint address hosts multiple services, in essence supports several WSDL descriptions, the desire to disambiguate messages should considered within the context of all the deployed services, not only within a single interface.
As explained in
any of these input elements within an interface has a value
of “#any”; or
more than one of these input elements (see below) has a
value of “#none”; or
the qualified names of the global element declarations that
are specified as input elements are NOT unique when
considered together.
element
attributes. Uniquely identifying a message may become very difficult when:
If any of the three cases above arise, then one of the following two alternatives can be used within the context of a single WSDL service by WSDL authors:
In addition, WS-Addressing [WS-Addressing] specification already provides a disambiguation mechanism. It defines a required [action] property whose value is always present in a message delivery. The value of the action property can be used to disambiguate the message by the receiver and there is a well defined way to associate actions to messages in WS-Addressing specifications. Further, WS-Addressing also provides an appropriate default action value that identifies each message uniquely.
A WSDL 2.0 document describes a set of messages that a Web service may send and receive. In essence, it describes a language for interacting with that service. However it is possible for a Web service to exchange other messages beyond those described in a particular WSDL 2.0 document. Often this circumstance occurs following an evolution of the client and/or service, and thus an evolution of the interaction language.
How best to manage the evolution (versioning) of Web based systems is, at the time of writing, the subject of a wide ranging debate. However, there are three activities within the W3C that are directly relevant to versioning of Web services description:
The
The
The
While incomplete, these activities all agree in one important respect: that versioning is difficult, but you should anticipate and plan for change.
The draft finding on Versioning and Extensibility details two key approaches to versioning:
compatible evolution; and
big bang.
In
The receiver behaves
correctly if it receives a message in an
The receiver behaves
correctly if it receives a message in a
Since Web services and their clients both send and receive messages, these concepts can apply to both parties. However, since WSDL 2.0 is service-centric, we will focus on the case of service evolution.
There are three critical areas in which a service described in WSDL 2.0 my evolve:
The service now also supports additional binding. In compatible evolution, this should be a safe addition, given that adding a new binding should not impact any existing interactions using another transport.
An interface supports new operations. Again, in compatible evolution this is usually safe, given that adding an additional operation to an abstract interface should not impact any existing interactions.
The message bodies may include additional data.
How the message contents may change within a description depends to
a large extent upon the type system being used to describe the message
contents. RelaxNG xs:any
and
xs:anyAttribute
constructs. XML Schema 1.1 has been chartered to
provide "changes necessary to provide better support for versioning of
schemas", and it is anticipated that this may include improved support
for more "open content" and therefore better support for compatible
evolution of messages.
The protocol used to exchange messages may provide mechanisms for exchanging data outside of the message body. In the case of SOAP, the WSDL 2.0 binding provides the ability to describe application data to be exchanged as headers. The SOAP processing model has a very good extensibility model with unknown headers being ignored by a receiver by default. There is also a mechanism whereby headers which are required as a part of an incompatible change may be marked with a 'mustUnderstand' flag. Passing additional items as headers may be the only way to compatibly evolve messages with fixed bodies.
The
Compatible changes are far more easily managed than incompatible ones:
With a compatible change the service need only support the latest version of a service. A client may continue to use a service adjusting to new version of the interface description at a time of its choosing.
With an incompatible change, the client receives a new version of the interface description and is expected to adjust to the new interface before old interface is terminated. Either the service will need to continue to support both versions of the interface during the hand over period, or the service and the clients are coordinated to change at the same time. An alternative is for the client to continue until it encounters an error, at which point it uses the new version of the interface.
It is feasible to combine the "compatible evolution" and "big bang" approaches in a variety of different ways. For example, the namespace could be changed when message descriptions are changed, but the namespace could stay the same when new operations are added.
While the big bang approach is currently the easiest to implement in WSDL 2.0, it can lead to a large number of cloned interfaces that become difficult to manage, thus making the compatible approach preferable to many for widely distributed systems. In the end, the choice of a versioning strategy for Web services described in WSDL 2.0 is left as an exercise to the reader.
The following example demonstrates how content may be extended with additional content. The reservation service is changed to a newer version that can accept an optional number of guests parameter. The service provider wants existing clients to continue to be able to use the service. The author adds the element into the schema as an optional element.
The author has the choice of keeping the same namespace or using a different namespace for the additional content and the existing content. In this scenario, it is a compatible change and the author decides to keep the same namespace. This allows existing clients to interact with a new service, and it allows newer clients to interact with older services.
Another option is to add the extension as a header block. This is accomplished by defining an element for the extension and adding a header element that references the element into the binding operation as child of the input.
It is also possible for the header to be marked with soap:mustUnderstand set to true. The HTTP Binding has similar functionality though without a mustUnderstand attribute.
This following example demonstrates an extension with additional content. The reservation service requires a number of guests parameter. The service provider wants existing clients to be unable to use the service. The author adds the element into the schema as a mandatory element.
The author has the choice of keeping the same namespace or using a different namespace for the additional content and the existing content. In this scenario, it is an incompatible change and the author decides to use a new name but the same namespace. This type is then used in the interface operation, and then binding and service endpoints.
Section
Often mandatory operations are added to an interface. The Hotel service decides to add an operation to the reservation service which is a confirmation. The Hotel service requires that all clients upgrade to the new interface to use the service. They have a variety of options for indicating that the old interface is deprecated.
By the definition of interface inheritance, they cannot use interface inheritance for defining the extension.
This interface cannot be bound and deployed at the existing URI and indicate incompatibility, as the service will still accept the makeReservation request. Changing the name of the interface from reservation to reservationWithConfirmation or changing the name of the operation from makeReservation to makeReservationV2 does not affect the messages that are exchanged. Thus it can't be used as a mechanism for indicating incompatibility. To indicate incompatibility, a change must be made to something that appears in the message. For a SOAP over HTTP request, the list is roughly the URI, the SOAP Action HTTP Header, or the Message content.
To indicate incompatibility, the URI of the Hotel Endpoint can be changed and messages send to the old Endpoint return a Fault.
The SOAP Action can be set for the makeReservation request, and making it different than the earlier version should indicate incompatibility.
Note that this mechanism is applicable on a per-binding basis. The SOAP HTTP Binding provides for setting Action, but other bindings may not provide such a facility.
The namespace or name of the makeReservation element can be changed, and then the interface and bindings changed. To indicate incompatibility, requests using the old makeReservation Qname should probably return a fault. The new interface, with a changed makeReservation, is:
The binding and service endpoints require no change.
Finally, the service could also provide an interface for ghns:makeReservation that only returns a fault.
Hyperlinking is one of the defining characteristics
of the Web. The ability to navigate from one Web
page to another is extremely useful. It is therefore
natural to apply this capability to Web services.
This section describes
A service reference is an element or attribute that contains one
or more endpoint references for a service.
An endpoint reference is an element or attribute
that contains the address of a Web service endpoint.
If the interface or binding that the endpoint
implements is known at description time, it may be
useful to add this information to the WSDL 2.0
document that describes the Web service. This is
accomplished by using the
One may wonder, from a Web architectural point of view, why anything more than a URI would be needed to reference a Web service. Indeed, a service reference does make use of one or more URIs to indicate the endpoint addresses of a service. However, it may also include additional metadata about that service, such as the WSDL 2.0 interface and binding that the service supports.
Service and endpoint references will be illustrated by expanding the GreatH example already discussed.
When designing a Web application it is natural to
give each important concept a URI. In the GreatH hotel
reservation system, the important concepts are
reservations, so we begin our design by assigning a
URI to each reservation. Since each reservation has
a unique confirmation number, e.g OMX736, we create
a URI for each reservation by appending the
confirmation number to a base URI, e.g.
http://greath.example.com/2004/reservation/OMX736.
This URI will be the endpoint address for a
Reservation Details Web service that can retrieve and
update the state of a reservation.
The Reservation Details Web service provides
operations for retrieving and updating the detail
for a reservation.
service
element in this description since the set of
reservations is dynamic. Instead, the endpoints for
the reservations will be returned by querying the
Reservation List Web service.
This XML schema contains the usual definitions for the elements
that appear in the messages of the Web service. For example, the
reservationDetails
element is used in the messages of the
retrieve
and
update
operations. In addition, the schema defines the simple type
reservationDetailsSOAPEndpointType
which is based on
xs:anyURI
and has the annotation
wsdlx:binding = "wdetails:reservationDetailsSOAPBinding"
which means that the URI is the address of a Reservation Details Web service
endpoint that implements the
wdetails:reservationDetailsSOAPBinding
binding. Note that the wdetails:reservationDetailsSOAPBinding
binding.
This annotated simple type is used to define the
Since the set of reservations changes as reservations are made and cancelled, the Reservation Detail endpoints are not described in a fixed WSDL 2.0 document. Instead they are returned as endpoint references in response to requests made on a Reservation List Web service. The endpoint for the Reservation List service will be http://greath.example.com/2004/reservationList.
Here, the
<details:reservationDetailsSOAPEndpoint>
elements contain endpoint references to the
Reservation Details Web services for the
reservations HSG635, OMX736, and WUH663.
In the preceding example, there was a single
endpoint associated with each Reservation Detail
Web service. Suppose GreatH hotel decided to
provide a second, secure endpoint. In this case,
service references would be used to collect
together the endpoints for each reservation. The
reservationDetails.xsd schema defines the
reservationDetailsService
element for this purpose. It contains the
nested elements reservationDetailsSOAPEndpointType
and therefore contain the address of an endpoint that implements
the wdetails:reservationDetailsSOAPBinding
binding.
This section presents a variation on the example in
Since each reservation in our example will have a distinct URI, the Reservation Details Web service can be offered using HTTP GET and HTTP PUT. The binding would be modified as follows:
As with the example in
This section continues the REST-style example of
The SOAP version of the Reservation List Web service above offers four different search operations. These can also be expressed as various parameters in a URI used by HTTP GET:
A retrieval by Confirmation Number URI would look
like:
http://greath.example.com/2004/reservationList/ConfirmationNumber/HSG635
.
Alternatively, a single query type may be provided. This query type is a sequence of optional items. Any items in the sequence are serialized into the URI query string. A query sequence for any of ConfirmationNumber, checkInDate, checkOutDate would look like this:
The WSDL 2.0 service that offers this type serialized as a parameter would look like this:
Various URIs would be:
http://greath.example.com/2004/reservationList/ReservationQuery?confirmationNumber=HSG635
http://greath.example.com/2004/reservationList/ReservationQuery?checkInDate=06-06-05
.
It is important to observe that using the URI serialization can result in very flexible queries and few operations. The previous discrete SOAP operations are collapsed into one "parameterized" operation.
Suppose a Web service wishes to expose two different interfaces: a customer interface for its regular users, and a management interface for its operator. A Declare both interfaces in the same wsdl:description element. Although WSDL 2.0 does not ascribe any particular significance to the fact that two wsdl:services are declared within the same wsdl:description, an application or toolkit could interpret this to mean that they are related in some way. Declare both interfaces in the same wsdl:targetNamespace. Again, although WSDL 2.0 does not ascribe any particular significance to the fact that two wsdl:services are declared within the same wsdl:targetNamespace, an application or toolkit could interpret this to mean that they are related in some way.
Add an extension to WSDL 2.0 that links together all services that are related in this way. WSDL 2.0's open content model permits extension elements from other namespaces to appear in a WSDL 2.0 document. Declare them in completely separate WSDL 2.0 documents, but use the same endpoint address for both. I.e., declare a Use inheritance to combine the customer interface and management interface into a single, larger wsdl:interface. Of course, this reduces modularity and means that the management interface becomes exposed to the customers, which is not good. wsdl:service
specifies only one wsdl:interface, so to achieve the desired effect the service provider would somehow need to indicate a relationship between two services. How can a service provider indicate a relationship between services? Potential strategies include:wsdl:interface
and wsdl:service
for the customer interface in one WSDL 2.0 document, and a wsdl:interface
and wsdl:service
for the management interface in a different WSDL 2.0 document, but use the same endpoint address for both. (By "different WSDL 2.0 document" we mean that both documents are never included or imported into the same WSDL 2.0 descriptions component.) Although this approach may work in some circumstances, it means that the same endpoint address would be used for two different purposes, which is apt to cause confusion or ambiguity. Furthermore, it is contrary to the Web architectural principle that different URIs should be used to identify different Web resources. (See the Web Architecture
Bear in mind that since the above strategies step outside of the WSDL 2.0 language specifies (and are therefore neither endorsed nor forbidden by the WSDL 2.0 specification) the WSDL 2.0 specification cannot define or standardize their semantics.
The desire to express relationships between services is also relevant to Web service versioning, discussed next.
WSDL 2.0 is a language designed primarily with XML syntax. While XML is almost universally understood, it has several issues:
The ability to compose two XML documents into one depends on the languages of those documents. WSDL 2.0 does not permit Web service descriptions in different targetNamespaces to be merged into a single (physical) XML document.
The ability to extend XML languages with other XML languages depends on the languages again. WSDL 2.0 is extremely extensible, but the meaning of every single extension in WSDL 2.0 must be defined explicitly. Putting a piece of XMI (XML format for UML) into a WSDL 2.0 document may have different meaning from putting it into an XHTML document. Therefore XML-based extensibility has very high cost if many languages are involved.
Similarly, extending another XML language with pieces of WSDL 2.0, while possible, has to be defined for all the possible destinations. Putting a WSDL 2.0 interface element into a UDDI registry may mean a different thing from putting that interface element into an XHTML document.
Finally, the meaning of a portion of a WSDL 2.0 document is not defined by the WSDL 2.0 specification. While an interface element could form a single XML document, it is not a WSDL 2.0 document, so its meaning is largely undefined.
Applications that require such levels of composability (or
decomposability) are increasingly being based on RDF
First, all components in WSDL 2.0 (like Interfaces, Operations, Bindings, Services, Endpoints etc., including extensions) are turned into resources identified with the appropriate URIs created according to @@Appendix C@@.
Further, things are represented as resources: Element declarations gathered from XML Schema (or
similarly, other components from other type systems) Message content models Message exchange patterns (the URI identifying the MEP
is the URI of the resource) Operation styles (similarly to MEPs, the URI of an
operation style is the URI of the resource)
All the resources above are given the appropriate types using rdf:type statements (an interface will belong to the class Interface and an operation within an interface will belong to the class InterfaceOperation, for example).
All relationships in WSDL 2.0 (like an Operation belonging to an
Interface and having a given operation style) are turned into
RDF statements using appropriate properties, such as operation
and operationStyle
.
It is a common misperception to equate either the target namespace of an XML Schema or the value of the
Throughout this document there are fully qualified URIs used
in WSDL 2.0 and XSD examples. In some cases, fully qualified URIs
were used simply to illustrate the referencing concepts. However, the use of
relative URIs is allowed and warranted in many
cases. For information on processing relative URIs, see
In general, when a WSDL 2.0 document is published for use by others, it should only contain URIs that are globally unique. This is usually done by allocating them under a domain name that is controlled by the issuer. For example, the W3C allocates namespace URIs under its base domain name, w3.org.
However, it is sometimes desirable to make
up a temporary URI for an entity, for use during development, but not make the URI globally unique
for all time and have it "mean" that version of the
entity (schema, WSDL 2.0 document, etc.).
This document is the work of the
Members of the Working Group are (at the time of writing, and by alphabetical order): Allen Brookes (Rogue Wave Softwave), Dave Chappell (Sonic Software), Helen Chen (Agfa-Gevaert N. V.), Roberto Chinnici (Sun Microsystems), Kendall Clark (University of Maryland), Ugo Corda (SeeBeyond), Glen Daniels (Sonic Software), Paul Downey (British Telecommunications), Youenn Fablet (Canon), Hugo Haas (W3C), Tom Jordahl (Macromedia), Anish Karmarkar (Oracle Corporation), Jacek Kopecky (DERI Innsbruck at the Leopold-Franzens-Universität Innsbruck, Austria), Amelia Lewis (TIBCO Software, Inc.), Michael Liddy (Education.au Ltd.), Kevin Canyang Liu (SAP AG), Jonathan Marsh (Microsoft Corporation), Josephine Micallef (SAIC - Telcordia Technologies), Jeff Mischkinsky (Oracle Corporation), Dale Moberg (Cyclone Commerce), Jean-Jacques Moreau (Canon), Mark Nottingham (BEA Systems, Inc.), David Orchard (BEA Systems, Inc.), Bijan Parsia (University of Maryland), Tony Rogers (Computer Associates), Arthur Ryman (IBM), Adi Sakala (IONA Technologies), Asir Vedamuthu (Microsoft Corporation), Sanjiva Weerawarana (Independent), Ümit Yalçınalp (SAP AG).
Previous members were: Lily Liu (webMethods, Inc.), Don Wright (Lexmark), Joyce Yang (Oracle Corporation), Daniel Schutzer (Citigroup), Dave Solo (Citigroup), Stefano Pogliani (Sun Microsystems), William Stumbo (Xerox), Stephen White (SeeBeyond), Barbara Zengler (DaimlerChrysler Research and Technology), Tim Finin (University of Maryland), Laurent De Teneuille (L'Echangeur), Johan Pauhlsson (L'Echangeur), Mark Jones (AT&T), Steve Lind (AT&T), Sandra Swearingen (U.S. Department of Defense, U.S. Air Force), Philippe Le Hégaret (W3C), Jim Hendler (University of Maryland), Dietmar Gaertner (Software AG), Michael Champion (Software AG), Don Mullen (TIBCO Software, Inc.), Steve Graham (Global Grid Forum), Steve Tuecke (Global Grid Forum), Michael Mahan (Nokia), Bryan Thompson (Hicks & Associates), Ingo Melzer (DaimlerChrysler Research and Technology), Sandeep Kumar (Cisco Systems), Alan Davies (SeeBeyond), Jacek Kopecky (Systinet), Mike Ballantyne (Electronic Data Systems), Mike Davoren (W. W. Grainger), Dan Kulp (IONA Technologies), Mike McHugh (W. W. Grainger), Michael Mealling (Verisign), Waqar Sadiq (Electronic Data Systems), Yaron Goland (BEA Systems, Inc.), Ümit Yalçınalp (Oracle Corporation), Peter Madziak (Agfa-Gevaert N. V.), Jeffrey Schlimmer (Microsoft Corporation), Hao He (The Thomson Corporation), Erik Ackerman (Lexmark), Jerry Thrasher (Lexmark), Prasad Yendluri (webMethods, Inc.), William Vambenepe (Hewlett-Packard Company), David Booth (W3C), Sanjiva Weerawarana (IBM), Charlton Barreto (webMethods, Inc.), Asir Vedamuthu (webMethods, Inc.), Igor Sedukhin (Computer Associates), Martin Gudgin (Microsoft Corporation).
The people who have contributed to