Home arrow Web Services arrow Notifications and Resources in the WS-Resource Framework

Notifications and Resources in the WS-Resource Framework

This article concludes our discussion of the WS-Resource Framework, a set of proposed standards that formalizes the relationship between Web services and state. In this part, we finish covering notifications and go into greater detail about resources. 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 / 4
July 20, 2006
  1. · Notifications and Resources in the WS-Resource Framework
  2. · Notification Consumers
  3. · Resource Lifetime
  4. · Initializing Termination Time
  5. · Notification of WS-Resource Termination
  6. · Other WS-Resource Framework Specifications

print this article

Notifications and Resources in the WS-Resource Framework
(Page 1 of 6 )

The Other Notification Producer Operation: GetCurrentMessage

The subscribe operation is by far the most important operation provided by a notification producer. Several other operations are also specified as part of a notification producer's portType.

GetCurrentMessage allows a requestor to pull notification messages from one of the topics provided by the notification producer. The requestor specifies a topic as a parameter of the GetCurrentMessage request message and, in response, the notification producer returns the last notification message (if any) that was associated with that topic. This operation might be used in combination with a subscribe message. For example, right after subscribing for changes to the poRP:status topic, The Skateboard Warehouse can immediately issue a GetCurrentMessage on that topic, capturing the current message associated with the poRP:status topic. The Skateboard Warehouse can use a GetCurrentMessage operation on any topic supported by our PurchaseOrder WS-Resource, even topics they aren't subscribed to.

Notification of Value Changes on Resource Properties

One aspect of WS-ResourceProperties that we haven't thoroughly examined yet is subscribing for value changes on a resource property. WS-ResourceProperties defines a convention on WS-Notification topics to standardize the way subscribers can subscribe to changes in a resource property. Essentially, WS-ResourceProperties declares a convention that for each resource property, a topic is defined to correspond to the QName of that resource property. This topic is associated with notification messages that depict value changes of that resource property.

For example, for the resource property named poRP:status, there exists a corresponding root topic named status in a topic space whose target namespace is the same as the namespace identified by the poRP prefix. In this way, it's simple to describe a topic expression for the topic containing notification messages for the situation where the value of a given resource property changes. That topic expression is the QName of the resource property.

If The Skateboard Warehouse is interested in subscribing to changes in the status of its PurchaseOrder, the subscription request contains the QName of the poRP:status resource property, as in the following portion of a subscribe request:

inventoryManagement </wsa:Address> </wsnt:ConsumerReference> <wsnt:TopicExpression dialect= "http://www.ibm.com/xmlns/stdwip/web-services/
simple"> poRP:status </wsnt:TopicPathExpression> ... </wsnt: Subscribe>

This is exactly the subscribe request we saw earlier in the chapter. For this subscribe request to work, the following things must hold:

  • The Web service component of the WS-Resource must support the operations from the NotificationProducer portType. If the Web service doesn't include the operations from NotificationProducer, it's impossible to subscribe to anything associated with that Web service, including value changes on any WS-Resource it's associated with.

  • The Web service component of the WS-Resource must include the poRP:status topic as a value within its Topic resource property. Recall from the section "Resource Properties of a Notification Producer" that all Web services that include the NotificationProducer operations must include this element in their resource properties document definition. If the Web service doesn't include a topic corresponding to a resource property in its Topic resource property, then it doesn't support value changes on that resource property. This situation may arise when the resource property changes too frequently or it's too expensive to detect the resource property change situation.

Even if the these conditions hold, and a subscriber successfully subscribes for value changes on a particular resource property, there is no guarantee that the notification consumer will receive a notification message tracking each and every value change of the resource property. This could happen because the resource property changes too frequently, or changes occur that the Web service is unable to detect.

All topics associated with a resource property value change situation contain the same pattern: the notification message must contain an element called ResourcePropertyValueChangeNotification defined by the WS-ResourceProperties specification. This element contains two parts: an optional oldValue element (the value of the resource property before the change situation occurred) and a mandatory newValue element (the value of the resource property after the change situation was detected).

Because the notification message of a resource property value change notification is well defined, subscribers can be sophisticated in using the selector component of the subscribe request. For example, if The Skateboard Warehouse wants to subscribe to receive notification when the status of its PurchaseOrder transitions from received to posted, it can issue a subscription expression targeting the poRP:status resource property value change notification topic with an XPath selector expression to narrow the particular notification message of interest:

inventoryManagement </wsa:Address> </wsnt:ConsumerReference> <wsnt:TopicExpression dialect= "http://www.ibm.com/xmlns/stdwip/web-services/
simple"> poRP:status </wsnt:TopicExpression> <wsnt:Selector dialect="http://www.w3.org/TR/1999/
="received" and
/*/wsrp:NewValue/poRP:status="posted") </wsnt:Selector>
</wsnt: Subscribe>

This subscription will deliver a notification message to the notification consumer only if the notification message on the topic caused the selector expression to evaluate to true. In this case, it would be a message that looks like

WS-ResourceProperties" xmlns:poRP="http://www.skatestown.com/ns/
poResourceProperties"> <wsrp:OldValue> <poRP:status>received</poRP:status> </wsrp:OldValue> <wsrp:NewValue> <poRP:status>posted</poRP:status> </wsrp:NewValue> </wsrp:ResourcePropertyValueChangeNotification>

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