|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
#include <stdio.h> |
|
|
|
|
|
#include <xmlrpc-c/base.h> |
|
|
#include <xmlrpc-c/client.h> |
|
|
|
|
|
#include "config.h" |
|
|
|
|
|
#define NAME "Xmlrpc-c Test Client" |
|
|
#define VERSION "1.0" |
|
|
|
|
|
static void |
|
|
dieIfFaultOccurred (xmlrpc_env * const envP) { |
|
|
if (envP->fault_occurred) { |
|
|
fprintf(stderr, "ERROR: %s (%d)\n", |
|
|
envP->fault_string, envP->fault_code); |
|
|
exit(1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
main(int const argc, |
|
|
const char ** const argv) { |
|
|
|
|
|
xmlrpc_env env; |
|
|
xmlrpc_value * resultP; |
|
|
xmlrpc_int32 sum; |
|
|
const char * const serverUrl = "http://localhost:8080/RPC2"; |
|
|
const char * const methodName = "sample.add"; |
|
|
|
|
|
if (argc-1 > 0) { |
|
|
fprintf(stderr, "This program has no arguments\n"); |
|
|
exit(1); |
|
|
} |
|
|
|
|
|
|
|
|
xmlrpc_env_init(&env); |
|
|
|
|
|
|
|
|
xmlrpc_client_init2(&env, XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION, NULL, 0); |
|
|
dieIfFaultOccurred(&env); |
|
|
|
|
|
printf("Making XMLRPC call to server url '%s' method '%s' " |
|
|
"to request the sum " |
|
|
"of 5 and 7...\n", serverUrl, methodName); |
|
|
|
|
|
|
|
|
resultP = xmlrpc_client_call(&env, serverUrl, methodName, |
|
|
"(ii)", (xmlrpc_int32) 5, (xmlrpc_int32) 7); |
|
|
dieIfFaultOccurred(&env); |
|
|
|
|
|
|
|
|
xmlrpc_read_int(&env, resultP, &sum); |
|
|
dieIfFaultOccurred(&env); |
|
|
printf("The sum is %d\n", sum); |
|
|
|
|
|
|
|
|
xmlrpc_DECREF(resultP); |
|
|
|
|
|
|
|
|
xmlrpc_env_clean(&env); |
|
|
|
|
|
|
|
|
xmlrpc_client_cleanup(); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|