Helma Logo
main list history

XML-RPC Sample


This sample uses the Jala extension to Helma, so you have to use Helma 1.6.x or get Jala from http://dev.orf.at/jala. You can add the Jala module by calling: app.addRepository('modules/jala/code/XmlRpcRequest.js').

You must create two Helma applications: xmlrpcserver and xmlrcpclient. No special configuration of Helma is necessary.


    function main_action_xmlrpc(methodName, param) {
        switch(methodName) {
            case "addDoc": 
                return this[methodName](param);
                return "method '" + methodName + "' not supported!";
        return ;

The first argument of the XML/RPC action is the method name. Arguments 1..n are the supplied arguments by the client. Note that you don't generate a response by writing to the res object, but by simply returning a XML-RPCable return value from the action.

    function addDoc(param) {
        return "added '" + param.name + "' to the search index.";

This is just how you could layout your XML/RPC actions.


    function main_action() {
        var xmlReq = new jala.XmlRpcRequest("http://localhost:8080/xmlrpcserver/", "addDoc");
        var xmlRes = xmlReq.execute({name: "ist einfach gut"});

In this example i am supplying a JSON-Object to be sent to the xmlrpcserver. You can send as many argument as you like. I would not send to complex datatypes. But integers, strings and JSON Objects are good.


You can change the XML/RPC Port in the Helma start script.
This can be start.bat or start.sh in your Helma home directory or if you use /etc/init.d/helma to start and stop your Helma instance you can change the configuration in /etc/helma.conf.