8int main(
int argc,
char* argv[] ) {
11 std::cerr <<
"Usage: HelloClient serverHost serverPort\n";
14 int port = atoi( argv[2] );
20 if ( c.
execute(
"system.listMethods", noArgs, result ) )
21 std::cout <<
"\nMethods:\n " << result <<
"\n\n";
22 else std::cout <<
"Error calling 'listMethods'\n\n";
27 if ( c.
execute(
"system.methodHelp", oneArg, result ) )
28 std::cout <<
"Help for 'Hello' method: " << result <<
"\n\n";
29 else std::cout <<
"Error calling 'methodHelp'\n\n";
32 if ( c.
execute(
"Hello", noArgs, result ) ) std::cout << result <<
"\n\n";
33 else std::cout <<
"Error calling 'Hello'\n\n";
37 if ( c.
execute(
"HelloName", oneArg, result ) ) std::cout << result <<
"\n\n";
38 else std::cout <<
"Error calling 'HelloName'\n\n";
45 std::cout <<
"numbers.size() is " << numbers.
size() << std::endl;
46 if ( c.
execute(
"Sum", numbers, result ) )
47 std::cout <<
"Sum = " << double( result ) <<
"\n\n";
48 else std::cout <<
"Error calling 'Sum'\n\n";
51 if ( c.
execute(
"NoSuchMethod", numbers, result ) )
52 std::cout <<
"NoSuchMethod call: fault: " << c.
isFault() <<
", result = " << result
54 else std::cout <<
"Error calling 'Sum'\n";
58 multicall[0][0][
"methodName"] =
"Sum";
59 multicall[0][0][
"params"][0] = 5.0;
60 multicall[0][0][
"params"][1] = 9.0;
62 multicall[0][1][
"methodName"] =
"NoSuchMethod";
63 multicall[0][1][
"params"][0] =
"";
65 multicall[0][2][
"methodName"] =
"Sum";
68 multicall[0][3][
"methodName"] =
"Sum";
69 multicall[0][3][
"params"][0] = 10.5;
70 multicall[0][3][
"params"][1] = 12.5;
72 if ( c.
execute(
"system.multicall", multicall, result ) )
73 std::cout <<
"\nmulticall result = " << result << std::endl;
74 else std::cout <<
"\nError calling 'system.multicall'\n";
A class to send XML RPC requests to a server and return the results.
bool execute(const char *method, XmlRpcValue const ¶ms, XmlRpcValue &result)
bool isFault() const
Returns true if the result of the last execute() was a fault response.
RPC method arguments and results are represented by Values.
int size() const
Return the size for string, base64, array, and struct values.