Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

XML and Web services (the beginning): XML-RPC and JAX-RPC

In this tip, William Brogden discusses why and how XML-RPC still deserves serious consideration.

The original XML-RPC protocol was invented by Web pioneer Dave Winer at UserLand Software in 1998 and first implemented in the UserLand Frontier development platform (in fact, UserLand Software has trademarked "XML-RPC"). The obvious utility of the "XML text transmitted over HTTP" approach subsequently led to the creation of SOAP, with contributions by Winer, Don Box, and others at Microsoft. However, it can be argued that SOAP has become grossly overweight with many features which are totally un-necessary for many applications, so XML-RPC still deserves serious consideration.

The original XML-RPC uses only a few data types and does not require namespaces. It achieves considerable flexibility by defining <struct> and <array> types which can contain other values. Here is an example request from the XML-RPC specification document which specifies single input parameter to the "getStateName" method in the "examples" application.

 <?xml version="1.0"?>

You have probably already deduced that the tag means a 4 byte integer, here are all the type tags used inside tags to specify how the contents are to be interpreted. String values are assumed if no type tag is used. Note that parameters are not named, the order of elements simply matches the order of method parameters.

Java Type   XML tag           Description
         A 32 bit signed integer
               A double precision (64bit) signed floating point number
               0 (false) or 1 (true)
Date or    
        A timestamp in the ISO8601 style but simplified Calendar with resolution to the second. byte[] 
         A base-64 encoded array of bytes Map 
          Pair(s) of 
            tags where the name is a string and the value can be any other type, including 
              An array of objects where the elements can be any other type. 

There is no way to specify a "null" value for any type in the original specification, but there are extended versions that allow additional types.

Responses are also simple XML with as the root element with either or as the child element. The contrast with complex SOAP responses is striking.

Implementations of XML-RPC

The implementations list at xmlrpc.com gives links to 79 different implementations of the basic XML-RPC protocol in a variety of languages, including five in Java as of December 2003. However, many of these projects appear to be inactive. The project hosted by the Apache Web Services Project is active. I tried running the current version, 3.0a1, but found that it had mysterious dependencies on other Web services project libraries. It looks like the Apache Web Services Project is on the right track with version 3, so keep an eye on it if you are interested in an open-source XML-RPC solution.

JAX-RPC: The Java API for XML-based RPC

The original push for a Java API was conducted as JSR 101. This effort was started in early 2001 and reached version 1.0 in mid 2002. Version 1.1 was released in 2003 with a reference implementation by Sun in the Java Web Services Developer Pack. In JAX-RPC, the definition of Java primitive types is tied to XML schema types. It also supports more Java standard library objects, for example BigInteger and BigDecimal, and objects that meet the JavaBeans standard. The people working on JSR 101 clearly had the parallel developments in SOAP and other XML technologies in mind.

The Java Web Services Developer Pack (JWSDP) version 1.6 contains, among many other things, an implementation of JAX-RPC 1.1.3.

JAX-WS 2.0: The Next JAX-RPC

The next version of the specification is now known as JAX-WS 2.0, for Java API for XML-Based Web Services instead of JAX-RPC. The development of the standard is being undertaken as Java Specification Request (JSR) 224 and is at the proposed final draft stage.

This next version of JAX-RPC is supposed to significantly reduce the complexity of Web service development, partly by making use of features in the Java 1.5 standard library. You can track the development of the reference implementation at the site shown in the resources list. As of this writing, early access version 3 of the reference implementation is available.

Working with JWSDP 1.6

One of the powerful capabilities in JWSDP 1.6 is Web Services Description Language (WSDL) support. Given a WSDL document describing a Web service, practically all of the client-side code required to access the service and/or the server-side code required to support the service can be generated automatically. In response to a client's request for a simple interface to a published Web service, I used the wscompile tool in JWSDP 1.6 to create client side classes for a WSDL that described 4 possible actions based on three or four input parameters. An astonishing 32 classes were created in a few seconds.

Once I figured out which of these classes provided the real starting point for creating a request, writing the code to provide a simple command line interface was simple. The problem came when I found that in order to run the program, the client would need to add 10 additional jar files from the JWSDP to his Java installation.

Since I was not prepared to help him debug the potential collisions of these jar libraries with other Java programs on his system, I discarded the whole mess and wrote a simple program using string templates to create the SOAP request and XPath to interpret the resulting replies. I concluded that, as the name implies, the JWSDP will mainly be useful to those creating Web services, not those consuming them.

Is XML-RPC Still Useful?

The complexity of the JAX-RPC implementation has caused somewhat of a backlash among programmers. Just try a Google search for "JAX-RPC complexity" to see some user reactions. It seems to me you should consider XML-RPC over JAX-RPC if:

  • Your application uses relatively simple requests
  • You control both server and client sides and/or you don't need to publish a WSDL
  • You want to keep client-side parsing simple (as in AJAX applications)


XML-RPC Specification

The W3C definition of WSDL

The JAX-WS 2.0 (JAX-RPC 2.0) Project

Apache Software Foundation - Apache XML-RPC

UserLand Frontier

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.