FileDocCategorySizeDatePackage
HelloClient.javaAPI DocExample3888Wed Sep 19 09:18:46 BST 2001javaxml2

HelloClient

public class HelloClient extends Object
HelloClient is a simple XML-RPC client that makes an XML-RPC request to HelloServer.

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