Hi Keroppi,
I think you're missing webServer.run(). Please see the attached example :)
Regards
Jason
--
Falun Gong: A peaceful meditation practice under persecution in China
http://www.faluninfo.net
Truth - Compassion - Forbearance
package myxmlrpc;
import org.apache.xmlrpc.WebServer;
public class MyXmlRpcServer
{
static WebServer webServer;
public MyXmlRpcServer()
{
}
public static void main(String[] args)
{
if (args.length != 1)
{
System.out.println("Usage: myxmlrpc.MyXmlRpcServer port");
System.exit(0);
}
try
{
System.out.println("Listen to the port : " + args[0]);
webServer = new WebServer(new Integer(args[0]).intValue());
XmlRpcSimple simple = new XmlRpcSimple();
// --------------------------------------------------------------------
// Registering simple XML-RPC
// --------------------------------------------------------------------
System.out.println("Registering simple XML-RPC ...");
webServer.addHandler("simple",simple);
System.out.println("Start the XML-RPC WebServer ...");
webServer.run();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
package myxmlrpc;
import org.apache.xmlrpc.XmlRpcHandler;
import java.util.Vector;
public class XmlRpcSimple
{
public XmlRpcSimple()
{
}
/**
* Simple sum of two integers
* @param a
* @param b
* @return
*/
public int sum(int a, int b)
{
System.err.println("simple.sum of " + a + " and " + b);
return (a+b);
}
public static void main(String[] args)
{
XmlRpcSimple xmlRpcSimple1 = new XmlRpcSimple();
}
}
package myxmlrpc;
import org.apache.xmlrpc.XmlRpcClient;
import java.util.Vector;
public class MyXmlRpcClient
{
public MyXmlRpcClient()
{
}
public static void main(String[] args)
{
if (args.length < 2)
{
System.out.println("Usage: myxmlrpc.MyXmlRpcClient host port");
System.exit(0);
}
try {
System.out.println("Connecting to " + args[0] + ",port: " + args[1]);
XmlRpcClient rpcClient = new XmlRpcClient(args[0],new Integer(args[1]).intValue());
if(args.length>=4)
{
System.out.println("Using proxy="+args[2]+":"+args[3]);
rpcClient.setHttpProxy(args[2],Integer.parseInt(args[3]),"","");
}
while(true) {
MyXmlRpcClient util = new MyXmlRpcClient();
// --------------------------------------------------------------------
// Calling simple XML-RPC
// --------------------------------------------------------------------
System.out.println("\nDoing simple.sum XML-RPC call ...");
Vector sumParam = new Vector();
sumParam.addElement(new Integer(5));
sumParam.addElement(new Integer(10));
Integer sumResult;
System.out.println("\tParam= " + sumParam);
sumResult = (Integer) rpcClient.execute("simple.sum",sumParam);
sumParam = null;
System.out.println("\tResult= " + sumResult);
Thread.sleep(2000);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}