开发者

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.


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


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>...
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜