FileDocCategorySizeDatePackage
HelloServer.javaAPI DocExample3524Wed Sep 19 09:19:06 BST 2001javaxml2

HelloServer

public class HelloServer extends Object
HelloServer is a simple XML-RPC server that will make the HelloHandler class available for XML-RPC calls.

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

Start up the XML-RPC server and register a handler.

        if (args.length < 1) {
            System.out.println(
                "Usage: java javaxml2.HelloServer [port]");
            System.exit(-1);
        }
    
        try {
            // Use the Apache Xerces SAX Driver
            XmlRpc.setDriver("org.apache.xerces.parsers.SAXParser");

            // Start the server
            System.out.println("Starting XML-RPC Server...");
            WebServer server = new WebServer(Integer.parseInt(args[0]));            
            
            // Register the handler class
            server.addHandler("hello", new HelloHandler());
            System.out.println(
                "Registered HelloHandler class to \"hello\"");            
            
            System.out.println("Now accepting requests...");                       
                        
        } catch (ClassNotFoundException e) {
            System.out.println("Could not locate SAX Driver");
        } catch (IOException e) {
            System.out.println("Could not start server: " + 
                e.getMessage());
        }