Question

I'm using xmlrpc-c as XMLRPC Client for my C project, my question is how can I pass following parameters to my Remote Procedure Call ?

string1, int1, string2, int2, struct (name : age), string3

Here is the cmdline tool of xmlrpc command
xmlrpc http://www.oreillynet.com/meerkat/xml-rpc/server.php meerkat.getItems struct/{search:linux,descriptions:i/76,time_period:12hour}

I want to pass similar parameter in my code.

Was it helpful?

Solution

Here I've found the solution any how...... whew....

xmlrpc_value *result, *params, *form_value;
xmlrpc_value *form2send;

form2send = xmlrpc_struct_new(env); // initialize the new structure
form_value = xmlrpc_build_value(env, "s", "");  // convert emtpy_string to xmlrpc_string
xmlrpc_struct_set_value(env, form2send, form_key, form_value);  // set key/value in structure

params = xmlrpc_build_value(env, "(sisS)", database, uid, password, form2send); // Capital `S` Denotes Structure 
fault_occurred(env, oo_plugin);

OTHER TIPS

I don't think that you can, so you would have to destructure the struct into seperate typed parameters and then rebuild the structure on the other side.

You can use a composed struct/array structure: the main structure would be an array, that holds the data. Some of them composed, like structures. However, you have to recompose the hash table in the receiving part. Data in the wire would be something like:

<array>
<data>
<value><string>string</string></value>
<value><struct><member><name>name</name></member><member><name>age</name>...
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top