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

15.3 SOAP Headers Example

HydraExpress ships with the example <installdir>\examples\webservices\Headerillustrating how to add and retrieve SOAP headers to a message. In this directory you will find a WSDL file, headers.wsdl, a server implementation, HeadersImp.cpp, and a client implementation, HeadersClient.cpp.

15.3.1 Client-Side Code

The client implementation of the invoke_addHeaders() method, which calls the addHeaders() service operation method in the proxy, adds a SOAP header to a rwsf::CallInfo object before sending the request message.

//1

Instantiates a rwsf::CallInfo object.

//2

Adds a request SOAP header element named MyHeader, in a namespace with the prefix headers, whose value is the literal string "MyValue".

//3

Calls the addHeaders() method in the proxy, passing the rwsf::CallInfo object containing the header data.

15.3.2 Server-Side Code

On the server side, the implementation HeadersImp.cpp retrieves the header data and adds a new header to the response message whose data is a modified version of the data in the request message header.

//1

Retrieves the header data into the variable headerValue.

//2

Adds a response SOAP header element named ServerHeader, in a namespace with the prefix headers, whose value is the request header data with the literal string ": From the server" appended.

15.3.3 Viewing the Results

Generate code, build the example (making sure to copy the provided client and server implementations to the app\client and app\server directories respectively), and deploy the server. If you need help, see the procedure in Chapter 3, "Creating a Web Service."


The provided implementations assume you have generated code using the default -STL option. If you use the -sourcepro option, the provided implementations will fail to compile.

From your command prompt, navigate to your HeadersExample\bin directory where the client executable has been placed.


HydraExpress's generated client sample implementations all point to the <project-directory>\conf directory to locate the client configuration files. If you move the client executable without maintaining the same code generation directory structure, or you invoke the client from another location, be aware that you must edit the client implementation to maintain the correct path to the conf directory.

Run the example by entering:

Windows prompt> HeadersClient.exe
Linux prompt> HeadersClient

The output shows the header data as returned from the server:

The output is generated by these lines in the client implementation:

To see the SOAP header as added to the request message by the client and as added to the response message by the server implementation, look at the log file log.out in the directory where you ran the example. The log shows the request SOAP message:

Here is the response:



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.