15int main(
int argc,
char* argv[] ) {
18 std::cerr <<
"Usage: FileClient serverHost serverPort requestXmlFile\n";
21 int port = atoi( argv[2] );
27 std::ifstream infile( argv[3] );
30 std::cerr <<
"Could not open file '" << argv[3] <<
"'.\n";
35 infile.seekg( 0L, std::ios::end );
36 long nb = infile.tellg();
39 char* b =
new char[nb + 1];
43 std::cout <<
"Read file.\n";
52 std::cerr <<
"Could not parse file\n";
59 std::cout <<
"Calling " << name << std::endl;
60 if ( c.
execute( name.c_str(), params, result ) ) std::cout << result <<
"\n\n";
61 else std::cout <<
"Error calling '" << name <<
"'\n\n";
62 std::cout <<
"Again? [y]: ";
65 if ( ans !=
"" && ans !=
"y" )
break;
73 const char METHODNAME_TAG[] =
"<methodName>";
74 const char PARAMS_TAG[] =
"<params>";
75 const char PARAMS_ETAG[] =
"</params>";
76 const char PARAM_TAG[] =
"<param>";
77 const char PARAM_ETAG[] =
"</param>";
82 XmlRpcUtil::log( 3,
"XmlRpcServerConnection::parseRequest: parsed methodName %s.",
90 std::cout <<
"Parsing arg " << nArgs + 1 << std::endl;
94 std::cerr <<
"Invalid argument\n";
97 std::cout <<
"Adding arg " << nArgs + 1 <<
" to params array." << std::endl;
98 params[nArgs++] =
arg;
102 XmlRpcUtil::log( 3,
"XmlRpcServerConnection::parseRequest: parsed %d params.", nArgs );
double arg(const EvtComplex &c)
std::string parseRequest(std::string const &xml, XmlRpcValue ¶ms)
A class to send XML RPC requests to a server and return the results.
bool execute(const char *method, XmlRpcValue const ¶ms, XmlRpcValue &result)
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
static std::string parseTag(const char *tag, std::string const &xml, int *offset)
Returns contents between <tag> and </tag>, updates offset to char after </tag>.
static bool findTag(const char *tag, std::string const &xml, int *offset)
Returns true if the tag is found and updates offset to the char after the tag.
static void log(int level, const char *fmt,...)
Dump messages somewhere.
RPC method arguments and results are represented by Values.
void setVerbosity(int level)
Sets log message verbosity. This is short for XmlRpcLogHandler::setVerbosity(level).