Folks, Thanks for the excellent implementation! Please tell me if what I have in mind has already been done or is too stupid to even contemplate. :-)
I have written a few XML-RPC methods and can call them via WebServer. I started writing JUnit tests for my methods and soon found myself writing a client stub for each method. It occurred to me that the stubs might be useful in contexts other than just testing. I realized that the stub generation might be automated with a little java.lang.reflect code yet to be written, assuming that I group my method signatures in a Java interface. Something like: interface Foo { ... } // XML-RPC method signatures XmlRpcClient client = ...; Foo proxy = (Foo) AutoProxy.create (Foo.class, client, "foo"); proxy.meth(arg); // Call "foo.meth" remotely! //////////////////////////////////////// /// The code yet to be written. JDK 1.3 required. :-( //////////////////////////////////////// package org.apache.xmlrpc; public class AutoProxy implements InvocationHandler { /** * java.lang.reflect.InvocationHandler implementation */ public Object invoke (Object proxy, Method meth, Object[] args) throws XmlRpcException, IOException { ... // translate meth/args into an XML-RPC call } /** * Create a proxy for the given methods (iFace) in the given * namespace (prefix). */ public static Object create (Class iFace, XmlRpcHandler client, String prefix) { AutoProxy handler = new AutoProxy (iFace, client, prefix); return Proxy.newInstance (iFace.getClassLoader(), new Class[] { iFace }, handler); } ... } I am thinking this might be a good opportunity to get my feet wet in the Java reflection API. What do you all think? Best regards, -John