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";
23 std::cout <<
"Error calling 'listMethods'\n\n";
28 if (c.
execute(
"system.methodHelp", oneArg, result))
29 std::cout <<
"Help for 'Hello' method: " << result <<
"\n\n";
31 std::cout <<
"Error calling 'methodHelp'\n\n";
34 if (c.
execute(
"Hello", noArgs, result))
35 std::cout << result <<
"\n\n";
37 std::cout <<
"Error calling 'Hello'\n\n";
41 if (c.
execute(
"HelloName", oneArg, result))
42 std::cout << result <<
"\n\n";
44 std::cout <<
"Error calling 'HelloName'\n\n";
51 std::cout <<
"numbers.size() is " << numbers.
size() << std::endl;
52 if (c.
execute(
"Sum", numbers, result))
53 std::cout <<
"Sum = " << double(result) <<
"\n\n";
55 std::cout <<
"Error calling 'Sum'\n\n";
58 if (c.
execute(
"NoSuchMethod", numbers, result))
59 std::cout <<
"NoSuchMethod call: fault: " << c.
isFault() <<
", result = " << result << std::endl;
61 std::cout <<
"Error calling 'Sum'\n";
65 multicall[0][0][
"methodName"] =
"Sum";
66 multicall[0][0][
"params"][0] = 5.0;
67 multicall[0][0][
"params"][1] = 9.0;
69 multicall[0][1][
"methodName"] =
"NoSuchMethod";
70 multicall[0][1][
"params"][0] =
"";
72 multicall[0][2][
"methodName"] =
"Sum";
75 multicall[0][3][
"methodName"] =
"Sum";
76 multicall[0][3][
"params"][0] = 10.5;
77 multicall[0][3][
"params"][1] = 12.5;
79 if (c.
execute(
"system.multicall", multicall, result))
80 std::cout <<
"\nmulticall result = " << result << std::endl;
82 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.