Saying Hello

If you’ve made it through these several pages of discussion, you probably are at least partially convinced that XML-RPC has some usefulness and that it might be the right solution for some of your development problems. To try to elaborate on XML-RPC, we now look at building some actual working Java code using XML-RPC. In the great tradition of programming, we start with a simple “Hello World” type program. We want to have our XML-RPC server register a handler. This handler takes in a Java String parameter, the user’s name, and returns “Hello” and the user’s name; for example, the method might return “Hello Brett” when invoked. Then we need a server to make our handler available for XML-RPC clients. Finally, we build a simple client to connect to the server and request the method invocation.

In a practical case, the XML-RPC server and handler would be on one machine, usually a heavy-duty server, and the client on another machine, invoking the procedure calls remotely. However, if you don’t have multiple machines available, you can still use the examples locally. Although this will be much faster than an actual client and server, you can still see how the pieces fit together and get a taste of XML-RPC.

Getting XML-RPC Libraries

As we said earlier, 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 ...

Get Java and XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.