FileDocCategorySizeDatePackage
WeatherClient.javaAPI DocExample1413Tue Oct 09 11:03:40 BST 2001com.ecerami.xmlrpc

WeatherClient

public class WeatherClient extends Object

Fields Summary
Constructors Summary
Methods Summary
public intgetWeather(java.lang.String zipcode)


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

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

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

            String resultStr = result.toString();
            int temperature = Integer.parseInt(resultStr);
            return temperature;
    
public static voidmain(java.lang.String[] args)

        WeatherClient client = new WeatherClient();
        int temperature;

        try {
            temperature = client.getWeather("10016");
            // Report the results
            System.out.println("Current Temperature: " + temperature);
        } catch (IOException e) {
            System.out.println("IO Exception: " + e.getMessage());
        } catch (XmlRpcException e) {
            System.out.println("Exception within XML-RPC: " + e.getMessage());
        }