A Java Client
import org.apache.xmlrpc.*;
public class JavaClient {
public static void main (String [] args) {
XmlRpcClient server = new XmlRpcClient("http://localhost/RPC2");
Vector params = new Vector();
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);
This line sends the request to the server. The procedure sum(17,13) is called on the server as if it were a local procedure. The return value of a procedure call is always an Object.
“sample” denotes a handler that is defined in the server.
- The parameters of the procedure call are always collected in a Vector.