Friday, 23 December 2011

XML-RPC Libraries

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
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 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.

Table 11-1. The XML-RPC classes

XmlRpcCore class allowing method calls on handlers by an XML-RPC server.
XmlRpcClientClass for client to use for RPC communication over HTTP, including proxy and cookie support.
XmlRpcClientLiteClass for client to use when a less-featured HTTP client is needed (no cookies, proxy support).
XmlRpcServerClass for servers to use to receive RPC calls.
XmlRpcServletProvides the functionality of XmlRpcServer in a servlet format.
XmlRpcProxyServletActs as an XML-RPC servlet proxy.
XmlRpcHandlerBase interface for controlling XML-RPC interactions by handlers.
AuthenticatedXmlRpcHandlerSame as XmlRpcHandler, but allows for authentication.
Base64Encodes and decodes between bytes and base 64 encoding characters.
BenchmarkTimes roundtrip XML-RPC interactions for a specific SAX driver.
WebServerA lightweight HTTP server for use by XML-RPC servers.
The SAX classes (from earlier examples) and a SAX driver are not included in the distribution, but they are required for operation. In other words, you need a complete XML parser implementation that supports SAX. I continue to use Apache Xerces in these examples, although the libraries support any SAX 1.0-compatible driver.
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.

1 comment:

  1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java Online Training from India. or learn thru Java EE Online Training Students.