mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 09:58:17 +00:00
add xmlrpc-c 1.03.14 to in tree libs
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3772 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
38
libs/xmlrpc-c/examples/cpp/xmlrpc_sample_add_client.cpp
Normal file
38
libs/xmlrpc-c/examples/cpp/xmlrpc_sample_add_client.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <xmlrpc-c/girerr.hpp>
|
||||
#include <xmlrpc-c/base.hpp>
|
||||
#include <xmlrpc-c/client_simple.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main(int argc, char **) {
|
||||
|
||||
if (argc-1 > 0) {
|
||||
cerr << "This program has no arguments" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
string const serverUrl("http://localhost:8080/RPC2");
|
||||
string const methodName("sample.add");
|
||||
|
||||
xmlrpc_c::clientSimple myClient;
|
||||
xmlrpc_c::value result;
|
||||
|
||||
myClient.call(serverUrl, methodName, "ii", &result, 5, 7);
|
||||
|
||||
int const sum = xmlrpc_c::value_int(result);
|
||||
// Assume the method returned an integer; throws error if not
|
||||
|
||||
cout << "Result of RPC (sum of 5 and 7): " << sum << endl;
|
||||
|
||||
} catch (girerr::error const error) {
|
||||
cerr << "Client threw error: " << error.what() << endl;
|
||||
} catch (...) {
|
||||
cerr << "Client threw unexpected error." << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user