2010年5月17日 星期一

XMLRPC-Client

/////////////////////////
1. Write the code
/////////////////////////

XMLRPCClient.java
{{{
import org.apache.xmlrpc.client.*;
import java.util.Vector;
import java.net.URL;
public class XMLRPCClient {

public static void main( String args[] ) throws Exception {

XmlRpcClient client = new XmlRpcClient();
XmlRpcClientConfigImpl conf = new XmlRpcClientConfigImpl();
conf.setServerURL(new URL("http://localhost:9999/"));
client.setConfig(conf);
Vector params = new Vector();
params.addElement( new Integer(3) );
params.addElement( new Integer(5) );
Object result = client.execute( "userInfo.sayHello", params );

if ( result != null ){
System.out.println( "Successfully pinged guest account." );
Object[] res = (Object[])result;
for(Object r : res)
System.out.println((Integer)r);
}
}
}

}}}


//////////////////////////////////////////////////
2. compile and executable the code
//////////////////////////////////////////////////
[Andy@t-ap188 row]$ javac -classpath ./lib/xmlrpc-server-3.0.jar:./lib/xmlrpc-client-3.0.jar:./lib/xmlrpc-common-3.0.jar:./lib/commons-httpclient-3.0.1.jar:./lib/commons-codec-1.3.jar:./:./lib/commons-logging.jar:./lib/ws-commons-util-1.0.1.jar:./lib/ws-commons-java5-1.0.1.jar XMLRPCClient.java


[Andy@t-ap188 row]$java -classpath ./lib/xmlrpc-server-3.0.jar:./lib/xmlrpc-client-3.0.jar:./lib/xmlrpc-common-3.0.jar:./lib/commons-httpclient-3.0.1.jar:./lib/commons-codec-1.3.jar:./:./lib/commons-logging.jar:./lib/ws-commons-util-1.0.1.jar:./lib/ws-commons-java5-1.0.1.jar XMLRPCClient
23
25



=== Reference ===
http://now9956.pixnet.net/blog/post/24453088

沒有留言:

張貼留言