Example: Accessing a service from Groovy or Java
The Groovy language bundles XMLRPC service in the download. That, and the fact Groovy is a dynamic scripting language, makes it an interesting language to use for XMLRPC applications.
This example uses the echo service elsewhere in this handbook.
On the serverProxy line enter the correct URL.
Go into the Administration >> Services section and click on the Keys tab. Click on Create Key, enter anything for the Application Title and leave the Domain blank. Then paste the value you're given into the value for apiKey.
Then for userName and password enter appropriate values.
In the line saying serverProxy.echo.echo enter any message you want to have printed.
Run the script using the command line: groovy echo.groovy
import groovy.net.xmlrpc.*
def serverProxy = new XMLRPCServerProxy("http://...your server URL .../services/xmlrpc")
def apiKey = ..apiKey..
def userName = ..user name..
def password = ..password..
def res = serverProxy.system.connect(apiKey)
def sessid = res.sessid
serverProxy.user.login(apiKey, sessid, userName, password) {
serverProxy.echo.echo(apiKey, sessid, "Hello, world").each() { println it }
}