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.
14 #include <xmlrpc-c/base.hpp>
15 #include <xmlrpc-c/registry.hpp>
16 #include <xmlrpc-c/server_abyss.hpp>
20 class sampleAddMethod : public xmlrpc_c::method {
23 // signature and help strings are documentation -- the client
24 // can query this information with a system.methodSignature and
25 // system.methodHelp RPC.
26 this->_signature = "ii"; // method's arguments are two integers
27 this->_help = "This method adds two integers together";
30 execute(xmlrpc_c::paramList const& paramList,
31 xmlrpc_c::value * const retvalP) {
33 int const addend(paramList.getInt(0));
34 int const adder(paramList.getInt(1));
36 paramList.verifyEnd(2);
38 *retvalP = xmlrpc_c::value_int(addend + adder);
46 const char ** const) {
48 xmlrpc_c::registry myRegistry;
50 xmlrpc_c::methodPtr const sampleAddMethodP(new sampleAddMethod);
52 myRegistry.addMethod("sample.add", sampleAddMethodP);
54 xmlrpc_c::serverAbyss myAbyssServer(
56 8080, // TCP port on which to listen
57 "/tmp/xmlrpc_log" // Log file
60 myAbyssServer.runConn(STDIN_FILENO);
61 /* This reads the HTTP POST request from Standard Input and
62 executes the indicated RPC.