Title: RE: Newbie- any java samples

http://ws.apache.org/xmlrpc/types.html

This url shows the java types that can be passed using XML-RPC.
All objects passed must be one of these types, including objects stored within other objects.
E.g A vector of strings is OK, however a vector of nodes is not.

http://ws.apache.org/xmlrpc/server.html

This url has some examples about server side implementation.  Try the "Using the Built-in HTTP Server" section.
webserver.addHandler ("examples", someHandler); is important.  someHandler is a class that you must create.  Methods to be used by xmlrpc must have a return value in the allowed types.  They cannot return null.

Try this code:

Create a class called TestHandler.class with one method,

public String testMethod(String inString)
{
        return "hello world.  you passed in: "+inString;
}

Give it an empty constructor.

Create another test class to run, with this main method:

public static void main(String[] args)
{
        try
        {
                TestHandler testHandler=new TestHandler();
                WebServer webserver = new WebServer (10001);
                webserver.addHandler ("TestHandler", testHandler);
                webserver.start();
                XmlRpcClientLite client=new XmlRpcClientLite("localhost",10001);
                Vector parameters=new Vector();
                parameters.add("hello xmlrpc server!");
                System.out.println(client.execute("TestHandler.testMethod",parameters));
        }
        catch(Exception e)
        {
                e.printStackTrace();
        }
}

There might be errors in this code, i didn't have time to test it, but it's a start. 


-----Original Message-----
From: Nookala, Sridevi (Sridevi) [mailto:[EMAIL PROTECTED]]
Sent: Friday, 19 August 2005 6:23 a.m.
To: '[email protected]'
Subject: Newbie- any java samples


Hi,

I am newbies to XML-RPC web services. Can anybody point me where i could get java examples for xml-rpc.

Especially how to pass java objects using XmlRpcClient synchronous calls

-thx,
Sri

Reply via email to