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.
NOTE: 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.
NOTE: 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:
 
headerValue = MyValue: From the server
The output is generated by these lines in the client implementation:
 
std::string headerValue =
info.getResponseSoapHeaderValue(rwsf::XmlName("ServerHeader",
rwsf::XmlNamespace("headers",
"http://www.roguewave.com/examples/webservice/headers")));
std::cout << "headerValue = " << headerValue << std::endl;
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:
 
RWSF:*** REQUEST BODY ***
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<headers:MyHeader
xmlns:headers="http://www.roguewave.com/examples/webservice/headers"
env:mustUnderstand="0">MyValue</headers:MyHeader>
</env:Header>
<env:Body>
<rw:addHeaders env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:rw="http://xml.roguewave.com/webservice/">
<in1 xsi:type="xsd:int">15</in1>
</rw:addHeaders>
</env:Body>
</env:Envelope>
RWSF Info: got reply, extracting...
Here is the response:
 
RWSF Info:*** RESPONSE BODY ***
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<headers:ServerHeader
xmlns:headers="http://www.roguewave.com/examples/webservice/headers"
env:mustUnderstand="0">MyValue: From the server</headers:ServerHeader>
</env:Header>
<env:Body>
<ns1:addHeadersResponse
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://xml.roguewave.com/webservice/">
<return xsi:type="xsd:int">15</return>
</ns1:addHeadersResponse>
</env:Body>
</env:Envelope>