Search code examples
cstructxml-rpcxmlrpcclient

how can I Pass hashtable like object through xmlrpc-c?


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.


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);