Home arrow Web Services arrow Page 5 - Web Services and Stateful Resources

Web Services and Stateful Resources

The WS-Resource Framework is a set of proposed standards that formalizes the relationship between Web services and state. If you do anything involving the Web and persistent data, you know how important this is. This article, the first of a multi-part series, examines that framework. It is excerpted from chapter 8 of the book Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, written by Steve Graham et al. (Sams; ISBN: 0672326418).

Author Info:
By: Sams Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
June 29, 2006
  1. · Web Services and Stateful Resources
  2. · Aspects of State
  3. · Stateful Resources
  4. · Role of WS-Addressing
  5. · Using the Endpoint Reference

print this article

Web Services and Stateful Resources - Using the Endpoint Reference
(Page 5 of 5 )

The other important part of the WS-Addressing specification is the way in which the endpoint reference is used by requestors to form Web service messages. The WS-Addressing specification requires that each binding type associated with the Web service define a set of rules that dictate how the components of the endpoint reference must be used to form request messages to the Web service pointed to by the endpoint reference. The specification itself defines only the rules specific to SOAP binding.

The SOAP rules are simple: The contents of the Address field must appear in the SOAP message's To header, and the contents of the reference properties element must appear as headers in the SOAP message. Here's an example SOAP message that represents a registration request (see Chapter 4 for more details) to a StockAvailableNotification service, as pointed to by the endpoint reference we showed earlier:

soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/
03/addressing" xmlns:tns="http://www.skatestown.com/services/
StockAvailableNotification"> <soap12:Header> <wsa:To> http://www.skatestown.com/services/
StockAvailableNotification </wsa:To> <wsa:Action> http://www.skatestown.com/services/
StockAvailableNotification#registration <wsa:Action> <tns:someProperty> ABC 123 </tns:someProperty> <ns1:Expiration xsi:type="xsd:dateTime" xmlns:ns1="http://www.skatestown.com/ns/
registrationRequest"> 2004-01-30T05:00:00.000Z </ns1:Expiration> </soap12:Header> <soap12:Body> <ns2:registration ... </soap12:Body> </soap12:Envelope>

The way the reference properties flow (as SOAP header elements of the message) is important to establish context for processing the message. The WS-Resource Framework exploits this feature, as you'll see later in this chapter.

SOAP Headers Defined by WS-Addressing

WS-Addressing also standardizes a collection of SOAP headers. You saw one of these SOAP headers in the previous example: the To header. The other headers are summarized in the Table 8.1.

Table 8.1 SOAP Headers Standardized by WS-Addressing

WS-Addressing SOAP Header



The destination header. WS-Addressing requires this header to appear on messages sent to a Web service pointed to by an endpoint reference. Its content is a copy of the contents of the Address element in the endpoint reference.


An optional header. It contains a copy of the endpoint reference of the Web service that is the intended recipient of the message. If this header appears, it may help middleware intermediaries to process and route the message.


An optional header that contains an endpoint reference of the Web service that created the message.


An optional header that contains an endpoint reference of a Web service to which any reply to the message should be sent. If this header doesn't appear, the receiver of the message can use the From element to send reply messages. This aspect of WS-Addressing is useful for asynchronous messaging situations where the network transport protocol can't be relied on to target the response message.


An optional header that contains an endpoint reference of a Web service to which any fault messages should be sent. If this header doesn't appear, the receiver of the message can use the ReplyTo or From element to send fault messages.


A mandatory element that contains a URI indicating the intent of the message.


An optional URI that uniquely identifies this message.


An optional collection of QName, URI pairs. This allows you to specify the relationship between this message and other messages in a domain-specific way.

We consistently use only two of these headers: To and Action; the others are optional. For more information on the use of the headers specified by WS-Addressing, refer to the WS-Addressing spec at http://www.ibm.com/developerworks/ webservices/library/ws-add/.

Please check back next week for the continuation of this article.

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- Dealing with Loose Coupling in a Service-Ori...
- Loose Coupling in a Service-Oriented Archite...
- Safety, Idempotence, and the Resource-Orient...
- The Resource-Oriented Architecture in Action
- Features of the Resource-Oriented Architectu...
- The Resource-Oriented Architecture
- Getting Started with Flex
- Automated Billing and Faxing for the Web
- An Introduction to Web Services
- The Foundations of Web Services: From Novice...
- Web Services Reengineering: Finishing Touches
- Fault Handling with Web Services
- Flow and Web Services
- Process Lifecycles and Web Services
- Business Processes and Web Services

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials