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

10.3 Implementing the Service

The implementation of this service takes place in three files:

The WeatherSummary example ships with implemented versions of these files, located in the example directory along with the WeatherSummary.wsdl. The discussions that follow are based on these provided implementations.

10.3.1 The Request-Response Operation

The code below is an excerpt from WeatherSummaryImp.cpp. It shows the message handler registration macro and the request-response operation method getSummary().

//1Create a WeatherSummary object.
//2Populate the object with some made-up data, except for the zip code, which is taken from the request. The C++ data binding created for the WeatherSummary XML element contains accessor and mutator methods for obtaining and modifying the data for any sub-elements of WeatherSummary.
//3Return the object, which gets translated into a SOAP message and sent back to the client.

10.3.2 The One Way and Notification Operations

One extra class is generated on the server side to support the notification pattern. The class WeatherSummaryNotificationProxy is a generated proxy used to send a message to the client.

10.3.2.1 The Notification Proxy

This file is very similar to the generated proxy on the client side, containing both asynchronous and synchronous service operation methods that can be used by the client. Here is a brief excerpt:

//1Derives from rwsf::ClientImp, as does the proxy on the client side.
//2Sets the transport.
//3Contains asynchronous or synchronous service operation methods.

10.3.2.2 Implementing One Way and Notification

Let's first look at an excerpt from WeatherSummaryImp.cpp showing the implementation for the one-way operation method updateWeather(). This implementation does not really do anything with the weather update, but uses the message's arrival as the event that triggers a call to the notification operation method weatherNotification() in the special-generated class WeatherSummaryNotificationProxy.

//1Creates an string object to hold the location for the service.
//2Tests whether the transportName_in parameter equals HTTP or HTTPS. If so, the location string is set to the appropriate scheme, http:// or https://.
//3If the scheme was set, uses the host_in and port_in parameters to construct a complete URL for the location.

In a real service, this would be supplied by the target client as part of a subscribe operation and would be a URL available across the Internet. For this example, the location to be used is based on the listener created in the client implementation (see below).
//4If the location string is unempty, creates an instance of the proxy by passing the location as a parameter.
//5The path that is followed if transportName_in is other than HTTP or HTTPS.
//6Creates an instance of the proxy by passing the transport name as a parameter.
//7Uses the weather update that has just arrived as the data sent in the notification message.

Once the notification message has been sent, the server immediately sends a solicit-response method, to see if the client wishes to renew receipt of weather updates. Obviously, in a real service, a different event would trigger the server's solicit message to renew.

10.3.3 The Solicit Response Operation

The following code in WeatherSummaryImp.cpp shows the solicit-response service operation method.

//1Creates a string renewal with the solicit message.
//2Sends the renewal string as part of the solicit-response service operation method weatherUpdateRenew().


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.