01 package com.flat502.rox.demo;
02
03 import java.net.URL;
04
05 import com.flat502.rox.client.XmlRpcClient;
06
07 /**
08 * A demo synchronous client illustrating the {@link com.flat502.rox.client.XmlRpcClient#execute(String, Object[], Class)}
09 * method.
10 */
11 public class SyncClientDemo {
12 /**
13 * Call each of the exposed methods on the remote demo server.
14 * @param args
15 * A list of parameters. Only the first is used and if
16 * present must be the URL of the remote server. This
17 * defaults to <code>http://localhost:8080/</code> if
18 * not specified.
19 */
20 public static void main(String[] args) {
21 try {
22 String url = "http://localhost:8080/";
23
24 if (args != null && args.length > 0) {
25 url = args[0];
26 }
27 System.out.println("Connecting to " + url);
28
29 XmlRpcClient client = new XmlRpcClient(new URL(url));
30 TimeInfo rsp = (TimeInfo)client.execute("example.getDate", null, TimeInfo.class);
31 System.out.println("getDate() returned with");
32 System.out.println(" today is "+rsp.today);
33 System.out.println(" info: "+rsp.info);
34 } catch (Exception e) {
35 e.printStackTrace();
36 }
37 }
38 }
|