3 // see http://ws.apache.org/xmlrpc/client.html for these classes
4 import org.apache.xmlrpc.XmlRpcException;
5 import org.apache.xmlrpc.client.XmlRpcClient;
6 import org.apache.xmlrpc.client.XmlRpcClientConfig;
7 import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
9 import java.util.HashMap;
10 import java.util.List;
13 public class SelfService extends XmlRpcClient {
15 public SelfService( String url ) throws Exception {
17 XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
18 config.setServerURL(new URL( url ));
19 this.setConfig(config);
22 private String canonicalMethod ( String method ) {
23 String canonical = new String(method);
24 if (!canonical.startsWith( "FS.SelfService.XMLRPC." )) {
25 canonical = "FS.SelfService.XMLRPC." + canonical;
30 private HashMap testResponse ( Object toTest ) throws XmlRpcException {
31 if (! ( toTest instanceof HashMap )) {
32 throw new XmlRpcException("expected HashMap but got" + toTest.getClass());
34 return (HashMap) toTest;
37 public HashMap execute( String method, List params ) throws XmlRpcException {
38 return testResponse(super.execute( canonicalMethod(method), params ));
41 public HashMap execute( String method, Object[] params ) throws XmlRpcException {
42 return testResponse(super.execute( canonicalMethod(method), params ));
45 public HashMap execute( XmlRpcClientConfig config, String method, List params ) throws XmlRpcException {
46 return testResponse(super.execute( config, canonicalMethod(method), params ));
49 public HashMap execute( XmlRpcClientConfig config, String method, Object[] params ) throws XmlRpcException {
50 return testResponse(super.execute( config, canonicalMethod(method), params ));