Connect to the XML-RPC server and make a request.
if (args.length < 1) {
System.out.println(
"Usage: java HelloClient [your name]");
System.exit(-1);
}
try {
// Use the Apache Xerces SAX Driver
XmlRpc.setDriver("org.apache.xerces.parsers.SAXParser");
// Specify the server
XmlRpcClient client =
new XmlRpcClient("http://localhost:8585/");
// Create request
Vector params = new Vector();
params.addElement(args[0]);
// Make a request and print the result
String result =
(String)client.execute("hello.sayHello", params);
System.out.println("Response from server: " + result);
} catch (ClassNotFoundException e) {
System.out.println("Could not locate SAX Driver");
} catch (MalformedURLException e) {
System.out.println(
"Incorrect URL for XML-RPC server format: " +
e.getMessage());
} catch (XmlRpcException e) {
System.out.println("XML-RPC Exception: " + e.getMessage());
} catch (IOException e) {
System.out.println("IO Exception: " + e.getMessage());
}