FileDocCategorySizeDatePackage
AreaClient.javaAPI DocExample1635Tue Oct 09 11:03:40 BST 2001com.ecerami.xmlrpc

AreaClient

public class AreaClient extends Object

Fields Summary
Constructors Summary
Methods Summary
public doubleareaCircle(double radius)


            // Create the client, identifying the server
            XmlRpcClient client =
                new XmlRpcClient("http://localhost:8899/");

            // Create the request parameters using user input
            Vector params = new Vector();
            params.addElement(new Double (radius));

            // Issue a request
            Object result =
               client.execute("area.circleArea", params);

            String resultStr = result.toString();
            double area = Double.parseDouble(resultStr);
            return area;
    
public static voidmain(java.lang.String[] args)

        if (args.length < 1) {
            System.out.println(
                "Usage: java AreaClient [radius]");
            System.exit(-1);
        }
        AreaClient client = new AreaClient();
        double radius = Double.parseDouble(args[0]);

        try {
            double area = client.areaCircle(radius);
            // Report the results
            System.out.println("The area of the circle would be: " + area);

        } catch (IOException e) {
            System.out.println("IO Exception: " + e.getMessage());
        } catch (XmlRpcException e) {
            System.out.println("Exception within XML-RPC: " + e.getMessage());
        }