Implementing the Request-Response Method Asynchronously
Following is the implementation of the request-response invoke() method in AsyncClient.cpp, the provided implementation of the client.
void invoke_longRunningMethod(AsyncProxy& proxy) //1
{
std::string input_in("Hello World");
std::string return_ret;
try {
std::cout << "Invoking longRunningMethod" << std::endl;
rwsf::CallInfo info;
rwsf::AsyncHandle handle =
proxy.longRunningMethodStart(info, input_in); //2
if(handle.isFinished()) { //3
return_ret = proxy.longRunningMethodEnd(handle); //4
// return_ret is ready for use!
// handle's callInfo has response headers, etc.
rwsf::CallInfo retInfo = handle.getCallInfo(); //5
}
else {
std::cout << "Still waiting" << std::endl;
return_ret = proxy.longRunningMethodEnd(handle); //6
}
std::cout << "Return value = " << return_ret << std::endl;
} catch(const rwsf::SoapFaultException& e) { //7
std::cout << "Fault Code: "
<< e.getFault().getFaultcode().asString() << std::endl;
std::cout << "Fault String: " << e.getFault().getFaultstring()
<< std::endl;
}
}