A lot of work has already gone into RPC, and more recently XML-RPC. Like using SAX, DOM, and JDOM for XML handling, there is no reason to reinvent the wheel when there are good, even exceptional, Java packages in existence for your desired purpose. The center for information about XML-RPC and links to libraries for Java as well as many other languages can be found at http://www.xmlrpc.com.
On Hannes's site is a description of the classes in his XML-RPC package and instructions. Download the archive file and expand the files into your development area or IDE. You should then be able to compile these classes; there is example servlets that requires the servlet classes (servlet.jar for Servlet API 2.2). You can obtain these classes with the Tomcat servlet engine by pointing your web browser to http://jakarta.apache.org. If you do not wish to play with the servlet example, the servlet classes are not required for the programs in this chapter.
The core distribution (which does not include the applet or regular expression examples in the downloaded archive) is made up of thirteen classes, all in the helma.xmlrpc package. These are in a ready-to-use format in the lib/xmlrpc.jar file of the distribution. The classes within that distribution are detailed briefly in Table 11-1.
|XmlRpc||Core class allowing method calls on handlers by an XML-RPC server.|
|XmlRpcClient||Class for client to use for RPC communication over HTTP, including proxy and cookie support.|
|XmlRpcClientLite||Class for client to use when a less-featured HTTP client is needed (no cookies, proxy support).|
|XmlRpcServer||Class for servers to use to receive RPC calls.|
|XmlRpcServlet||Provides the functionality of XmlRpcServer in a servlet format.|
|XmlRpcProxyServlet||Acts as an XML-RPC servlet proxy.|
|XmlRpcHandler||Base interface for controlling XML-RPC interactions by handlers.|
|AuthenticatedXmlRpcHandler||Same as XmlRpcHandler, but allows for authentication.|
|Base64||Encodes and decodes between bytes and base 64 encoding characters.|
|Benchmark||Times roundtrip XML-RPC interactions for a specific SAX driver.|
|WebServer||A lightweight HTTP server for use by XML-RPC servers.|
Once you have all the source files compiled, ensure that the XML-RPC classes, SAX classes, and your XML parser classes are all in your environment's classpath. This should have you ready to write your own custom code and start the process of "saying hello." Keep the XML-RPC source files handy, as looking at what is going on under the hood can aid in your understanding of the examples.