|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <cassert> |
|
|
#include <cstdlib> |
|
|
#include <string> |
|
|
#include <iostream> |
|
|
#include <unistd.h> |
|
|
#include <signal.h> |
|
|
|
|
|
using namespace std; |
|
|
|
|
|
#include <xmlrpc-c/girerr.hpp> |
|
|
#include <xmlrpc-c/base.hpp> |
|
|
#include <xmlrpc-c/client.hpp> |
|
|
#include <xmlrpc-c/client_transport.hpp> |
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
main(int argc, char **) { |
|
|
|
|
|
if (argc-1 > 0) { |
|
|
cerr << "This program has no arguments" << endl; |
|
|
exit(1); |
|
|
} |
|
|
|
|
|
#ifndef _WIN32 |
|
|
|
|
|
|
|
|
|
|
|
signal(SIGPIPE, SIG_IGN); |
|
|
#endif |
|
|
|
|
|
try { |
|
|
xmlrpc_c::clientXmlTransport_pstream myTransport( |
|
|
xmlrpc_c::clientXmlTransport_pstream::constrOpt() |
|
|
.fd(STDIN_FILENO)); |
|
|
|
|
|
xmlrpc_c::client_xml myClient(&myTransport); |
|
|
|
|
|
string const methodName("sample.add"); |
|
|
|
|
|
xmlrpc_c::paramList sampleAddParms; |
|
|
sampleAddParms.add(xmlrpc_c::value_int(5)); |
|
|
sampleAddParms.add(xmlrpc_c::value_int(7)); |
|
|
|
|
|
xmlrpc_c::rpcPtr myRpcP(methodName, sampleAddParms); |
|
|
|
|
|
xmlrpc_c::carriageParm_pstream myCarriageParm; |
|
|
|
|
|
|
|
|
myRpcP->call(&myClient, &myCarriageParm); |
|
|
|
|
|
assert(myRpcP->isFinished()); |
|
|
|
|
|
int const sum(xmlrpc_c::value_int(myRpcP->getResult())); |
|
|
|
|
|
|
|
|
cout << "Result of RPC (sum of 5 and 7): " << sum << endl; |
|
|
|
|
|
} catch (exception const& e) { |
|
|
cerr << "Client threw error: " << e.what() << endl; |
|
|
} catch (...) { |
|
|
cerr << "Client threw unexpected error." << endl; |
|
|
} |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|