Creating a Request Handler
First, we'll create a request handler to handle requests for both the client and the server. A request handler processes the message body itself.
This example uses rwsf::CallInfo’s isClient() method (Response Handlers) to determine whether the request is client or server-based, and then either adds the SOAP header, or gets its value. Here is the included class SoapSecurityHandler.
#include <rwsf/webservice/MessageHandler.h>
class SoapSecurityHandler: public rwsf::MessageHandlerImp { //1
virtual void invoke(rwsf::CallInfo& callInfo)
// is this the client?
if(callInfo.isClient()) { //2
rwsf::XmlName("Security"), "SomeSecurityData");
else { //3
std::string value = callInfo.getRequestSoapHeaderValue(
// add the value back to the response headers
rwsf::XmlName("SecurityResponse"), value + ": From Server");
//1 Derives from rwsf::MessageHandlerImp.
//2 If isClient is true, this is the client and not the server. If it’s the client, let’s add a request SOAP header containing security data.
//3 Or, if this is the server, get the client’s SOAP header and add it to the response header.