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);
}
};
Now that you’ve created your handlers, they are ready to add to the client proxy.