package com.kingsoft.xmlrpc03;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpc;
import org.apache.xmlrpc.XmlRpcClient;
import org.apache.xmlrpc.XmlRpcException;
/**
* Xmlrpc客户端
*
* @author 朱玉成
*
*/
public class XmlClient {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// 打开调试模式
XmlRpc.debug = true;
XmlRpcClient client = null;
try {
client = new XmlRpcClient(Util.URL);
// 调用远程方法,把服务器返回结果放入Hashtable集合中
Hashtable<String, String> result = (Hashtable<String, String>) client
.execute("server.doService", new Vector());
// 取出放入Hashtable中的结果
String res1 = result.get("Hello");
String res2 = result.get("World");
// 打印服务器执行结果
System.out.println("result1 : " + res1);
System.out.println("result2 : " + res2);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (XmlRpcException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
- 1
- 2
前往页