You don't have to put an XmlRpcBean annotation to every bean you like to transfer. XmlRpc-Delight can use any unknown type as XmlRpcBean by setting
XmlRpc.XmlRpc.treatUnknownTypesAsBeans( true );
Also you can pass null-values as method arguments by setting
XmlRpc.useAutomaticNullMasking( true );
This has to be done on both server and client side.
public interface Api { enum Size { tiny, medium, huge } class Bean { private Size size; private String[] content; public Size getSize() { return size; } public void setSize( Size size ) { this.size = size; } public String[] getContent() { return content; } public void setContent( String[] content ) { this.content = content; } @Override public String toString() { return "Bean(" + getSize() + "):" + Arrays.toString( getContent() ); } } void updateBean( Bean b ); }
... //start server XmlRpc.treatUnknownTypesAsBeans( true ); XmlRpc.useAutomaticNullMasking( true ); StartXmlRpcServer.startXmlRpcServer( new ApiHandler() ); //create a (remote) client to the API Api api = createClient( Api.class ); //do some calls Api.Bean bean = new Api.Bean(); bean.setSize( Size.medium ); bean.setContent( new String[]{ "a", "b", "c" } ); api.updateBean( bean ); //also null values allowed Api.Bean bean2 = new Api.Bean(); bean2.setSize( Size.tiny ); bean2.setContent( null ); api.updateBean( bean2 ); ...
Examples in source code: http://delight.opendfki.de/repos/trunk/delight-examples/src/main/java/de/dfki/util/xmlrpc/examples/no_annontations
Last modified 14 years ago
Last modified on 06/29/10 14:17:10