i wrote xmlrpc-c bindings for vala. if somebody wants to commit it.. it's attached. i find it easier than using Soup. not really integrated with vala, check test case. On Thu, 02 Sep 2010 08:53:59 +1200 Phil Daintree <phil logicworks co nz> wrote:
I am trying to use libsoup's XML-RPC client methods to get data from a remote application .. using genie (or vala if necessary!). I have shamelessly taken much of this from an example I found on the net .... thanks to Evan! I have had some success using the code: [indent=4] /* Build with "valac --thread --pkg libsoup-2.4 yourfile.gs */ uses Soup Gee struct LocQty quantity : double loccode : string init var session = new Soup.SessionAsync () ItemCode:string = "DVD-TOPGUN" UserName:string = "admin" Password:string = "weberp" var message = Soup.xmlrpc_request_new ("http://localhost/webERP/api/api_xml-rpc.php", "weberp.xmlrpc_GetStockBalance", typeof(string),ItemCode, typeof(string), UserName, typeof(string), Password) session.send_message(message) ResponseData:string = message.response_body.flatten().data MessageLength : int = (int) message.response_body.length try xmlrpc_parse_method_response (ResponseData, MessageLength, typeof(int)) print("Stock of %s = %s",ItemCode, ResponseData) except print("Could not get webERP API location stock over XML-RPC.") print ("message length = %d",MessageLength) I get a nice response from the web-server : Stock of DVD-TOPGUN = <?xml version="1.0"?> <methodResponse> <params> <param> <value><array> <data> <value><int>0</int></value> <value><array> <data> <value><struct> <member><name>quantity</name> <value><string>-1</string></value> </member> <member><name>loccode</name> <value><string>MEL</string></value> </member> </struct></value> <value><struct> <member><name>quantity</name> <value><string>0</string></value> </member> <member><name>loccode</name> <value><string>TOR</string></value> </member> </struct></value> </data> </array></value> </data> </array></value> </param> </params> </methodResponse> I am figuring that the xmlrpc_extract_method_response is the method to parse the returned xml into an array of structs?? But I can't figure out how to use it and can find no examples on the net... Would appreciate any ideas? Phil ----- End forwarded message ----- _______________________________________________ vala-list mailing list vala-list gnome org http://mail.gnome.org/mailman/listinfo/vala-list
Attachment:
xmlrpc.vapi
Description: Text Data
Attachment:
xmlrpc-test.vala
Description: Text Data