Creating a Transport Handler
A transport handler processes the message after it is created and before it is transported. Our transport handler will process both the request and the response. Let’s look at the transport handler class, StringReverseHandler.
 
#include <rwsf/webservice/MessageHandler.h>
 
class StringReverseHandler : public rwsf::MessageHandlerImp { //1
 
public:
virtual void invoke(rwsf::CallInfo& callInfo)
{
std::string data;
 
if(callInfo.isRequest()) //2
data = callInfo.getRequest();
else
data = callInfo.getResponse();
 
std::string newData;
newData.reserve(size_t(data.length()));
 
for(int i = data.length()-1; i >= 0; --i) { //3
newData.append(data[i]);
}
 
if(callInfo.isRequest()) //4
callInfo.setRequest(newData);
else
callInfo.setResponse(newData);
}
};
//1 Derives from rwsf::MessageHandlerImp.
//2 If isRequest is true, this is a request from a client, so get it. Otherwise, this is a response from the server, so get that.
//3 Reverse the bytes in the message. This just demonstrates how to change the message before it is sent over the transport.
//4 If this is a request, add the changed message to the request; otherwise, add it to the response.
Now that you’ve created your handlers, they are ready to add to the client proxy.