programme serveur:

import org.apache.xmlrpc.*;

public class JavaServer
{
public Integer sum(int x, int y)
{
return new Integer(x+y);
}

public static void main (String [] args)

{
try
{

System.out.println("Attempting to start XML-RPC Server...");
WebServer server = new WebServer(80);
server.addHandler("sample", new JavaServer());
server.start();
System.out.println("Started successfully.");
System.out.println("Accepting requests. (Halt program to stop.)");
}
catch (Exception exception)
{
System.err.println("JavaServer: " + exception);
}
}
}

résultat d'exécution:

Attempting to start XML-RPC Server...
Started successfully.
Accepting requests. (Halt program to stop.)



programme client sur la même machine:

import java.util.Vector;
import org.apache.xmlrpc.*;


public class JavaClient
{
public static void main(String[] args) {
try {

XmlRpcClient server = new XmlRpcClient("http://localhost/RPC2");
Vector<Integer> params = new Vector<Integer>();
params.addElement(new Integer(17));
params.addElement(new Integer(13));

Object result = server.execute("sample.sum", params);

int sum = ((Integer) result).intValue();
System.out.println("The sum is: "+ sum);

} catch (Exception exception) {
System.err.println("JavaClient: " + exception);
}
}

}

résultat d'exécution:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
at org.apache.xmlrpc.XmlRpc.createTypeFactory(XmlRpc.java:238)
at org.apache.xmlrpc.XmlRpc.<init>(XmlRpc.java:193)
at org.apache.xmlrpc.XmlRpcClientResponseProcessor.<init>(XmlRpcClientResponseProcessor.java:48)
at org.apache.xmlrpc.XmlRpcClientWorker.<init>(XmlRpcClientWorker.java:43)
at org.apache.xmlrpc.XmlRpcClient.getWorker(XmlRpcClient.java:347)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:190)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:184)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:177)
at JavaClient.main(JavaClient.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 9 more

il n y a pas de faute dans le code java .merci de m'aider