Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Web Service Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

9.2 Message Patterns in WSDL

The W3C WSDL Specification defines four message patterns to support four types of operations:

Given the definition of the input and output messages for the operation in the WSDL file, HydraExpress generates the appropriate code for all four message patterns.

This section discusses each message pattern, with an introduction to the WeatherSummary.wsdl that is used for illustration. It also includes a brief discussion on synchronous and asynchronous behavior as it relates to message patterns.

9.2.1 Weather Summary Service Description

The Weather Summary service represents a centralized provider of weather condition data for some number of zip code locations in some area.

To complete this scenario, there should be another request-response operation that allows a zip code location to either subscribe or unsubscribe from the notification service, receiving a confirmation message in reply. This operation has been left out for the sake of simplicity.

9.2.2 The Request-Response Pattern

The request-response operation includes one input element, which is the client's request to the server, followed by one output element, which is the server's response back to the client.

Figure 1: The Request-response message pattern

In WeatherSummary.wsdl, the request-response operation is defined by the getSummary operation:

The operation getSummary contains an input message getSummary, which is the client request, and an output message getSummaryResponse, which is the server response. The contents of these messages are then defined in the WSDL's message element:

The message getSummary contains one part, a zipcode of type xsd:string. The client request thus provides a zipcode to the server.

The message getSummaryResponse contains one part, a weatherData object of type wsx:WeatherSummary. Based on the zipcode, the server return an XML WeatherSummary element for the location specified by the zipcode.

A WeatherSummary element is a complex type defined by an embedded XML Schema in the types element of the WSDL file. See Section 6.3.2, "The Generated Data Types."

The implementation of this pattern occurs in the client-side WeatherSummaryClient.cpp, a sample implementation that uses the generated class in WeatherSummaryProxy.cpp, and in the server-side WeatherSummaryImp.cpp, the server implementation that receives the request and sends a response.

For more information on the request-response pattern, see the examples discussed in Part I, "Getting Started," as well as those in Part IV, "Extending your Applications."

9.2.3 The One Way Pattern

The one-way operation includes one input element, which is the client's request to the server. No response is expected.

Figure 2: The One-way message pattern

In WeatherSummary.wsdl, the one-way pattern is defined by the operation updateWeather:

The operation updateWeather consists of one input message containing several parts.

The message contains a WeatherSummary element that provides updated weather conditions for the zip code.

The implementation of this pattern occurs in the client-side WeatherSummaryClient.cpp, a sample implementation that uses the generated class in WeatherSummaryProxy.cpp, and in the server-side WeatherSummaryImp.cpp, the server implementation that receives the request.

9.2.4 The Notification Pattern

The notification operation includes one output element, which is the server's message to the client.

Figure 3: The Notification message pattern

In WeatherSummary.wsdl, the notification pattern is defined by the operation weatherNotification:

The operation consists of one output message from the server to one or more clients.

The message contains a WeatherSummary element with updated weather conditions for the zip code specified in the WeatherSummary element.

HydraExpress uses special notification architecture to support this pattern. This architecture is described in Chapter 13, "Asynchronous Messaging."

This pattern is implemented on the server side by WeatherSummaryImp.cpp which makes the call to the weatherNotification() operation method in the server-side notification proxy WeatherSummaryNotificationProxy.cpp, and on the client side in WeatherSummaryNotificationImp.cpp, which sets up a listener on the client to receive the notification.

For an additional examples on the notification pattern, see Chapter 10,

9.2.5 The Solicit-Response Pattern

The solicit-response operation includes one output element, which is the server's request to the client, followed by one input element, which is the client's response back to the server.

Figure 4: The Solicit-response message pattern

In WeatherSummary.wsdl, the solicit-response pattern is defined in the operation weatherUpdateRenew.

This operation consists of one output message RenewRequest and one input message RenewResponse defined below.

This is the request message from the server to the client containing a simple string asking if the client wishes to renew the subscription to weather updates.

This is the response message from the client back to the server, also containing a string, to either affirm or deny the renewal of weather updates.

This pattern requires the server to initiate a message and the client to receive one, so it uses the notification architecture to support this pattern. This architecture is described in Section 9.3, "Architecture of the Notification Classes."

This operation is implemented on the server side in WeatherSummaryImp.cpp, which makes the call to the notification proxy in WeatherSummaryNotificationProxy.cpp to send the renewal request to the client. On the client side, the class in WeatherSummaryNotificationImp.cpp sets up a listener, receives the message, and sends a response.

9.2.6 Message Patterns and Asynchronicity

The request-response and the solicit-response patterns are generally synchronous, as their usage usually assumes that the requestor will receive an immediate response.

The one-way and the notification patterns are inherently asynchronous in that the requestor expects no response.

While one of the strengths of WSDL is that it allows any mix of message patterns and transports in a single service, it is important to be aware that the behavior of a service is tied to the type of transport being used. For example, an asynchronous service will not behave asynchronously if it is sent using a synchronous transport, such as HTTP. This is because HTTP requires a response as a receipt.

For this reason, it may be wise to build one-way and notification messages asynchronously even though no response is required, in order to avoid having the client block for a transport receipt. In addition, using the asynchronous methods for one-way and notification builds more responsiveness and adaptability into your program without much more complication.

For a general discussion on building services asynchronously, see Chapter 13, "Asynchronous Messaging."



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.