Bclient.java
import org.apache.xmlrpc.*;
import java.util.*; // for Vector
import java.net.*; // for MalformedURLException
import java.io.*; // for IOException
/**
Simple test client for XML-RPC.
*/
public class Bclient
{
public static void main(String[] argv)
{
String answer;
Vector params = new Vector(2);
try {
XmlRpcClient c =
new XmlRpcClient("http://localhost:9090/");
params.addElement("This is a test, bozo!");
answer = (String)c.execute("other.reverse",params);
System.out.println("Reverse: " + answer);
params.set(0,"key1");
params.addElement("value1");
answer = (String)c.execute("put",params);
System.out.println("put() response: " + answer);
params.set(0,"key2");
params.set(1,"value2");
answer = (String)c.execute("put",params);
System.out.println("put() response: " + answer);
params.set(0,"key1");
answer = (String)c.execute("get",params);
System.out.println("get() response: " + answer);
// Try to make the server fail...
params.set(0,"key3");
answer = (String)c.execute("get",params);
System.out.println("get() response: " + answer);
}
catch (XmlRpcException eXml) {
System.out.println("Exception in Bclient: " + eXml);
}
catch (MalformedURLException eUrl) {
eUrl.printStackTrace();
}
catch (IOException eIO) {
eIO.printStackTrace();
}
}
}