FileDocCategorySizeDatePackage
HelloClient.javaAPI DocExample3621Fri Jun 02 15:57:12 BST 2000None

HelloClient

public class HelloClient extends Object
HelloClient is a simple XML-RPC client that makes an XML-RPC request to HelloServer.
author
Brett McLaughlin
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

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());
        }