Software Development

Web Service Using Apache XML-RPC



This articles demonstrates how to use Apache XML-RPC in Java command-line applications. We will create programs both for XML-RPC server and client.

Software Environment

  • Windows 7 Professional SP1
  • Eclipse – Kepler Release
  • Java 1.7 (1.7.0_67 – Windows x86)
  • Apache Commons Codec 1.7
    • Download from Choose file name with *current* substring.
    • Used by the XML-RPC client
  • Apache Commons HttpClient 3.0
    • Download from
    • Used by the XML-RPC client
  • Apache XML-RPC 3.1.3
    • Download from
  • Apache Tomcat 7.0.56
    • We’ll reference and use only the servlet-api.jar file from Tomcat.
    • Used by the XML-RPC server only

The Eclipse Project


XML-RPC is the precursor of SOAP. Before writing the codes, you need to create a Java project in Eclipse. Then, download the files and manually put them in a folder (in this case, the “lib” folder) within the project. Lastly, reference all these jar files.


The XML-RPC Server

When creating a server, you need three (3) things:

  1. Your service class.
    It is a POJO whose methods can be invoked by remote clients, of course, via XML-RPC and through the XML-RPC server.
    This is where you register your service class so that the XML-RPC server can route RPC calls to appropriate object and method. If you have worked on Servlets, the file is like your web.xml for this command line application.IMPORTANT: This file needs to be in org.apache.xmlrpc.webserver package. Simply, create this package in your project and move or save the .properties file there.
  3. A reference to servlet-api.jar
    This is used by the ServletWebServer class

Your XML-RPC server is written something like this:

Register your service class on this file. Note that you need a fully-qualifed name of the class. On this article, my CalculartorWebService class resides in the default package.

The XML-RPC Client

Both the server and client applications can be ran in Eclipse.

Sample Output


To test both server and client in Eclipse, open and run it first.

xml-rpc-001 xml-rpc-002

Once the server is up and running, go the the file and run it.


Download the Project


You Might Also Like