File: hello_client.c

package info (click to toggle)
xmlrpc-epi 0.54.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,588 kB
  • sloc: sh: 12,254; ansic: 5,747; xml: 1,387; makefile: 166; php: 17
file content (58 lines) | stat: -rw-r--r-- 1,521 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* This is a simple demonstration of an xmlrpc client. This program
 * constructs an xmlrpc request and sends it to stdout. The output
 * is suitable for input to ./hello_server. 
 */

#include <stdio.h>
#include <stdlib.h>
#include "xmlrpc.h"

int main(int argc, char **argv)
{
  /* args */
  XMLRPC_REQUEST request;
  XMLRPC_VALUE xParamList;
  STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS output = {{0}};

  /* create a new request object */
  request = XMLRPC_RequestNew();

  /* Set the method name and tell it we are making a request */
  XMLRPC_RequestSetMethodName(request, "hello");
  XMLRPC_RequestSetRequestType(request, xmlrpc_request_call);

  /* tell it to write out xml-rpc (default). options are: 
   * xmlrpc_version_1_0        // xmlrpc 1.0
	* xmlrpc_version_simple		 // simpleRPC
	* xmlrpc_version_soap_1_1	 // soap 1.1
	*/
  output.version = xmlrpc_version_1_0;
  XMLRPC_RequestSetOutputOptions(request, &output);

  /* Create a parameter list vector */
  xParamList = XMLRPC_CreateVector(NULL, xmlrpc_vector_array);
  
  /* Add our name as first param to the parameter list. */
  XMLRPC_VectorAppendString(xParamList, NULL, "john galt", 0);

  /* add the parameter list to request */
  XMLRPC_RequestSetData(request, xParamList);

  {
     /* serialize client request as XML */
     char *outBuf = XMLRPC_REQUEST_ToXML(request, 0);

     if(outBuf) {
        printf(outBuf);
        free(outBuf);
     }
  }

  if(request) {
     /* Free request */
     XMLRPC_RequestFree(request, 1);
  }
  
  return 0;
}