Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive


Below is an extremely simple xmlrpc client. This does not support multicalls or any other fancy functionality. This simply gives you the bare bones functionality.

I'm posting this here not as a question but simply as a reference and as a ploy to coax the Titanium devs to formally support the xmlrpc protocol.


Simple xmlrpc client for sending requests and receiving results via a callback using standard Titanium http client mechanics.

Spec: http://www.xmlrpc.com/spec


// string url: the full url to the server side xmlrpc script
// string method: the name of the xmlrpc method to call
// array params: list of strings to send
// func callback: callback function to call "onload"
function xmlrpc(url, method, params, callback)
    Titanium.API.info("xmlrpc: begin");
    Titanium.API.info("xmlrpc: url: " + url);
    Titanium.API.info("xmlrpc: method: " + method);

    var xhr = Titanium.Network.createHTTPClient();
    xhr.onload = callback;
    var xml = '<methodCall>';
    xml += '<methodName>'+method+'</methodName>';
    xml += '<params>';
    for (var k in params)
        if (k)
            var p = params[k];
            Titanium.API.info("xmlrpc: p: "+p);
            xml += '<param><string>'+p+'</string></param>';
    xml += '</params></methodCall>';
    Titanium.API.info("xmlrpc: xml: "+xml);
    Titanium.API.info("xmlrpc: end");

Save the above code into an xmlrpc.js file. Example use below:

var rpc_url = "http://example.com/xmlrpc.php";
function rpc_cb()
    // you could use this.responseXML here too, this is just an example!
    Titanium.API.info('Received: '+this.responseText);

var params = ['foobar'];
— asked March 11th 2010 by Kevin Krinke
  • rpc
  • xml
  • xmlrpc

8 Answers

  • Thanks, I have been wandering around in the darkness for the last two days, hoping to find some ray of light that would help me understand where the actual UI was located, I think I see that it is in the sandbox, anyway your example helped in ways I cannot begin to relate, thanks again.

    — answered March 13th 2010 by Tim Franklin
  • @Joe Wheaton:

    Be aware that if your xmlrpc.php script does not understand the "somesite.echo" rpc method then the callback will not be called. There is obviously no real error handling for this case. If I find the time I'll update this example with an error handling callback example. Don't know when I'll get to that though. No promises.

    @Everyone else:

    You're welcome!

    — answered April 29th 2010 by Kevin Krinke
  • I don't know how to thank you. This is seriously amazing! I got it working easily and it's saved me a LOT of headache! I just can't thank you enough. :D


    — answered January 7th 2012 by Inder J
  • I've tried this several times and I can't seem to get it to work. As is the callback function never gets called(possible bug). I modified it to use the receive method instead of send. It then calls the callback but there is nothing in the responseText, responseXML, or responseData.

    Desktop Application
    Titanium Developer 1.2.1

    — answered April 15th 2010 by Joe Wheaton
  • I got this working on the first try. Thanks for the help.

    — answered April 28th 2010 by Justin Hall
    1 Comment
    • Hi can you give me some sample. so it will be more useful for me to implement.
      I am new to titanium. Just want to test possibility then ill go with titanium.


      — commented April 30th 2014 by Ravikumar Shanmugam
  • i am getting the following error as a XML Response

    <?xml version="1.0" encoding="UTF-8"?>
    <value><string>Param must contain a value</string></value>

    can any one help me with this.

    — answered February 21st 2012 by Abhishek Sharma
    1 Comment
    • sorry for posting the above, i found the answer to the problem, my request did not contain a <value></value> tag. Once adding a value tag solved the problem, thats what the error message says.

      — commented February 21st 2012 by Abhishek Sharma
  • That example doesnt work for me neither. It never finds the method to call. Any working alternatives?

    — answered April 19th 2012 by Marcel Klapschus
  • Hi there,
    I came across this post in my search for a method to do xml-rpc calls. Thanks for your solution. I also made it more of a module to support all data types and parse the result. Hopefully someone finds it handy, https://gist.github.com/ceramedia/5626950

    — answered May 22nd 2013 by Sven Groot
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.