56 | | === Using XML-RPC compliant types in your API === #ExampleUsingXmlRpcCompliantTypes |
57 | | |
58 | | '''Server side''' |
59 | | |
60 | | - The server side defines an API to be used remotely over XML-RPC. Additionaly an implementation |
61 | | of the API is hosted on the server-side |
62 | | |
63 | | {{{ |
64 | | interface Api { |
65 | | String getStatusMessage( int code ); |
66 | | } |
67 | | |
68 | | class Impl implements Api { |
69 | | public String getStatusMessage( int code ) {...} |
70 | | } |
71 | | }}} |
72 | | |
73 | | - register implementation as XML-RPC handler with the server |
74 | | |
75 | | {{{ |
76 | | WebServer xmlRpcServer = new WebServer( port ); |
77 | | xmlRpcServer.addHandler( "handlerId", XmlRpcHandlerFactory.createHandlerFor( new Impl() ); |
78 | | xmlRpcServer.start(); |
79 | | }}} |
80 | | |
81 | | '''Client side''' |
82 | | |
83 | | - create a remote client the use the API by simply calling a single method |
84 | | |
85 | | {{{ |
86 | | Api remote_api = XmlRpc.createClient( Api.class, "handlerId", host, port ); |
87 | | String msg = remote_api.getStatusMessage( 42 ); |
88 | | ... |
89 | | }}} |
| 56 | === Using own concete types === # ExampleUsingOwnConceteTypes |