ervice orientation is sweeping through modern enterprise environments like the Black Plague swept through Europe (hopefully the parallels end there). At the same time, enterprises seem increasingly interested in supporting thin clients and mobile interfaces. The convergence of these trends presents new challenges and more complex requirements, which enterprise developers can help address by choosing the best messaging protocol.
A service is a platform-neutral and typically coarse-grained interface to one or more business systems that can be invoked across a network. Wireless networks complicate this invocation process because the service provider must account for dropped packets and hops across multiple relays. Consequently, wireless clients must keep their exchanges as thin as possible to ensure optimum performance. Additionally, mobile devices typically do not have an abundance of resources for processing fat requests, synchronous request-response exchanges, or storing robust data models.
Its extremely lightweight XML grammar makes XML-RPC the ideal remote procedure-calling protocol for these service-oriented mobile computing scenarios, where application size, memory, and bandwidth are top priorities. (See "Sidebar 1. Why XML-RPC and Not SOAP".) For Java developers, kXML-RPC, the XML-RPC implementation for the Java Platform, Micro Edition (Java ME), offers a mechanism for enabling their mobile applications to communicate with enterprise services. (See "Sidebar 2. kXML-RPC vs. JAX-RPC".)
This article demonstrates how to build and run a Java mobile application that implements kXML-RPC on the client side to access a web service example. It includes a complete downloadable sample of all the code.
What You Need
The heart of this tutorial is the kXML-RPC library. As such, to build and run the example, you will need the following:
- Sun Java Wireless Toolkit for CLDC 2.5.1: This toolkit provides an emulation environment including the build tools for developing mobile applications. You will use the Wireless Toolkit (WTK) to compile and run the mobile client-side code.
- kXML-RPC 1.1 full binary: This library enables developers to perform XML-RPC calls for Java ME (CLDC) applications. The kXML-RPC binary does the grunt work of XML parsing and serialization of the service messages.
Installing the WTK should be straightforward; just follow the product's installation instructions and refer to its documentation for the system requirements. The WTK is available only for Windows XP and Linux.