1 /* A simple standalone XML-RPC server based on Abyss that contains a
2 simple one-thread request processing loop.
4 xmlrpc_sample_add_server.cpp is a server that does the same thing, but
5 does it by running a full Abyss daemon in the background, so it has
6 less control over how the requests are served.
12 #include <xmlrpc-c/base.hpp>
13 #include <xmlrpc-c/registry.hpp>
14 #include <xmlrpc-c/server_abyss.hpp>
18 class sampleAddMethod : public xmlrpc_c::method {
21 // signature and help strings are documentation -- the client
22 // can query this information with a system.methodSignature and
23 // system.methodHelp RPC.
24 this->_signature = "i:ii"; // method's arguments are two integers
25 this->_help = "This method adds two integers together";
28 execute(xmlrpc_c::paramList const& paramList,
29 xmlrpc_c::value * const retvalP) {
31 int const addend(paramList.getInt(0));
32 int const adder(paramList.getInt(1));
34 paramList.verifyEnd(2);
36 *retvalP = xmlrpc_c::value_int(addend + adder);
44 const char ** const) {
46 xmlrpc_c::registry myRegistry;
48 xmlrpc_c::methodPtr const sampleAddMethodP(new sampleAddMethod);
50 myRegistry.addMethod("sample.add", sampleAddMethodP);
52 xmlrpc_c::serverAbyss myAbyssServer(
54 8080, // TCP port on which to listen
55 "/tmp/xmlrpc_log" // Log file
59 cout << "Waiting for next RPC..." << endl;
61 myAbyssServer.runOnce();
62 /* This waits for the next connection, accepts it, reads the
63 HTTP POST request, executes the indicated RPC, and closes