/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Utilities/JobInfoSvc/JobInfoSvc-00-00-02/xmlrpc++0.7/test/HelloClient.cpp

Go to the documentation of this file.
00001 // HelloClient.cpp : A simple xmlrpc client. Usage: HelloClient serverHost serverPort
00002 // Link against xmlrpc lib and whatever socket libs your system needs (ws2_32.lib 
00003 // on windows)
00004 #include "XmlRpc.h"
00005 #include <iostream>
00006 using namespace XmlRpc;
00007 
00008 int main(int argc, char* argv[])
00009 {
00010   if (argc != 3) {
00011     std::cerr << "Usage: HelloClient serverHost serverPort\n";
00012     return -1;
00013   }
00014   int port = atoi(argv[2]);
00015   //XmlRpc::setVerbosity(5);
00016 
00017   // Use introspection API to look up the supported methods
00018   XmlRpcClient c(argv[1], port);
00019   XmlRpcValue noArgs, result;
00020   if (c.execute("system.listMethods", noArgs, result))
00021     std::cout << "\nMethods:\n " << result << "\n\n";
00022   else
00023     std::cout << "Error calling 'listMethods'\n\n";
00024 
00025   // Use introspection API to get the help string for the Hello method
00026   XmlRpcValue oneArg;
00027   oneArg[0] = "Hello";
00028   if (c.execute("system.methodHelp", oneArg, result))
00029     std::cout << "Help for 'Hello' method: " << result << "\n\n";
00030   else
00031     std::cout << "Error calling 'methodHelp'\n\n";
00032 
00033   // Call the Hello method
00034   if (c.execute("Hello", noArgs, result))
00035     std::cout << result << "\n\n";
00036   else
00037     std::cout << "Error calling 'Hello'\n\n";
00038 
00039   // Call the HelloName method
00040   oneArg[0] = "Chris";
00041   if (c.execute("HelloName", oneArg, result))
00042     std::cout << result << "\n\n";
00043   else
00044     std::cout << "Error calling 'HelloName'\n\n";
00045 
00046   // Add up an array of numbers
00047   XmlRpcValue numbers;
00048   numbers[0] = 33.33;
00049   numbers[1] = 112.57;
00050   numbers[2] = 76.1;
00051   std::cout << "numbers.size() is " << numbers.size() << std::endl;
00052   if (c.execute("Sum", numbers, result))
00053     std::cout << "Sum = " << double(result) << "\n\n";
00054   else
00055     std::cout << "Error calling 'Sum'\n\n";
00056 
00057   // Test the "no such method" fault
00058   if (c.execute("NoSuchMethod", numbers, result))
00059     std::cout << "NoSuchMethod call: fault: " << c.isFault() << ", result = " << result << std::endl;
00060   else
00061     std::cout << "Error calling 'Sum'\n";
00062 
00063   // Test the multicall method. It accepts one arg, an array of structs
00064   XmlRpcValue multicall;
00065   multicall[0][0]["methodName"] = "Sum";
00066   multicall[0][0]["params"][0] = 5.0;
00067   multicall[0][0]["params"][1] = 9.0;
00068 
00069   multicall[0][1]["methodName"] = "NoSuchMethod";
00070   multicall[0][1]["params"][0] = "";
00071 
00072   multicall[0][2]["methodName"] = "Sum";
00073   // Missing params
00074 
00075   multicall[0][3]["methodName"] = "Sum";
00076   multicall[0][3]["params"][0] = 10.5;
00077   multicall[0][3]["params"][1] = 12.5;
00078 
00079   if (c.execute("system.multicall", multicall, result))
00080     std::cout << "\nmulticall  result = " << result << std::endl;
00081   else
00082     std::cout << "\nError calling 'system.multicall'\n";
00083 
00084   return 0;
00085 }

Generated on Tue Nov 29 23:14:44 2016 for BOSS_7.0.2 by  doxygen 1.4.7