You are on page 1of 4

WS-Addressing

Every time we get a new innovation, eventually the "old world" of applications tries to use it to its advantage.
We had the web, which was designed for documents, and eventually everyone was creating "web enabled
applications". Now we have web services, and everyone's creating "web services applications". If you look at it
in a more general sense, we even have "Service Oriented Architectures". I'm sure it's not the first time that a
"new" way of doing things was co-opted and absorbed by the old way, and I'm even more sure it won't be the
last. But this need to adapt web services to the old way of creating programs creates a need to get around
some of the things about web services that were considered great in the first place.

For example, web services are inherently stateless. You make a call, and you get a result. Technically, that's
the end of the association between sender and receiver. But if you've ever tried to create any kind of serious
application, you know that that's hardly the end of it. You know that you often need to pass information that
approximates a state, such as a message identifier or a session id.

Then there's the matter of parameters. In a traditional API, you have methods and functions and properties (oh
my!) and you pass and receive values. Sure, you can approximate that in a SOAP message, but that would
mean fundamentally changing the way that you think about programming. And That Will Not Do, apparently.

So to that end, we have the need to create a web service in such a way that we can program with it as we
would program with any other language or environment. We need to be able to uniquely identify a service or a
service instance, we ned to be able to pass parameters back and forth.

It has to be standard.

In other words, it doesn't do any good to solve all of those problems if everybody solves them differently. To
that end, one proposed method that is gathering steam, particularly when it comes to Grid Computing, is WS-
Addressing.

WS-Addressing has two basic functions: to provide a standard way of referencing endpoints, and to provide a
standard set of headers providing information about a message, such as where it's going and where replies
and faults should go. Let's start by looking at endpoint references.

The purpose of endpoint references is to provide a way to give more information that a simple URL can
provide. For example, consider this endpoint reference, slightly modified from our discussion on Web Services
Resource Framework:

<wsa:EndpointReference>
<wsa:Address>
http://www.example.com/services/someService
</wsa:Address>
<wsa:ReferenceProperties>
<tns:resourceID>DataChunk42</tns:resourceID>
</wsa:ReferenceProperties>
<wsa:ReferenceParameters>
<tns:expires>32000</tns:expires>
</wsa:ReferenceParameters>
</wsa:EndpointReference>

In this case, we have an endpoint with two pieces of information: the address of the serivce, and a reference
property. Endpoint references can have five different types of information:

• address: The address is a URI (such as a URL) the represents the location of the service and identifies it.
This information is required.

• reference properties: This peices of information (such as the one in the example above) help to identify
the resource to which the service refers.

• reference parameters: This information is anything else that helps to facilitate the interaction.

• selected port type: The primary portType of the endpoint being conveyed, as defined in the WSDL file.

• service-port: Also referencing the WSDL definition of the service, the service-port points to the service
element that describes the service.

• policy: This information refers to WS-Policy elements.

The Address element represents the location of the service, so there's no need to represent it in a message,
but the SOAP binding specifies that all other information is to be included in the Header of the SOAP
message. So this endpoint might receive a SOAP message of:

<SOAP-ENV:Envelope>
<SOAP-ENV:Header>
<tns:resourceID>DataChunk42</tns:resourceID>
<tns:expires>32000</tns:expires>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
...
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Now, this isn't the only information that WS-Addressing specifies. It also defines Message Information Headers,
or specific bits of information about a message that also get included in the SOAP header. For example, we
could specify that this message was from http://www.example.com/clients/someClient, and that the
reply should go to http://www.example.com/clients/someOtherClient. We could even send any
faults to yet a third endpoint. We can also specify an action, which is similar to the old SOAPAction header:

<SOAP-ENV:Envelope>
<SOAP-ENV:Header>
<wsa:MessageID>msgid:1234567902282223</wsa:MessageID>
<wsa:To>http://www.example.com/services/someService</wsa:To>
<wsa:Action>http://www.example.com/someAction</wsa:Action>
<wsa:From>http://www.example.com/clients/someClient</wsa:From>
<wsa:ReplyTo><wsa:Address>http://www.example.com/clients/someOtherClie
nt</wsa:Address></wsa:ReplyTo>
<wsa:FaultTo><wsa:Address>http://www.example.com/clients/yetAnotherCli
ent</wsa:Address></wsa:FaultTo>
<tns:resourceID>DataChunk42</tns:resourceID>
<tns:expires>32000</tns:expires>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
...
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Notice that the ReplyTo and FaultTo are endpoint references, and not simple URIs. When we send a
response, we put some of this information to use:

<SOAP-ENV:Envelope>
<SOAP-ENV:Header>
<wsa:MessageID>msgid:1234567902282429</wsa:MessageID>
<wsa:RelatesTo>msgid:1234567902282223</wsa:RelatesTo>
<wsa:To>http://www.example.com/clients/someOtherClient</wsa:To>
<wsa:Action>http://www.example.com/someOtherAction</wsa:Action>
<wsa:From>
<wsa:Address>http://www.example.com/services/someService</wsa:Ad
dress>
<wsa:ReferenceProperties>
<tns:resourceID>DataChunk42</tns:resourceID>
</wsa:ReferenceProperties>
<wsa:ReferenceParameters>
<tns:expires>32000</tns:expires>
</wsa:ReferenceParameters>
</wsa:From>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
...
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

In this case, the RelatesTo element serves to tie the two messages together, and the From element
represents an endpoint reference.

Message Information Headers include the following:

• To: This is the destination of the message, and is required.

• Action: Expressed as a URI, this property is required.

• MessageID: The message id is only required if you are using ReplyTo or FaultTo.

• RelatesTo: When used in a reply, this property ties the message back to the original request. Other
possible roles may be defined for this element using the RelationshipType attribute..

• ReplyTo: This optional property contains an endpoint reference for the endpoint that is to receive the
reply, if any. If this element is not present, the reply is sent back to the original requestor.

• From: Optional, this property refers to the endpoint reference of the requestor of the current message.

• FaultTo: Represents the destination endpoint reference for any faults generated by the operation.

WS-Addressing generally enhances WSDL, and is designed to work with it. For example, the WSDL file can
contain references to WS-Addressing elements, and vice versa.

You might also like