Hangin with the JAX Pack, Part 4: JAX-RPCby Al Saganich
In my prior articles, I've introduced and discussed various aspects of the JAX Pack, a set of APIs for working with Web services and the underlying supporting protocols. In this article, we'll look at JAX-RPC, a specification for making remote procedure calls via XML and SOAP over HTTP. Specifically we'll look at the client side of JAX-RPC, as it shows the most promise.
Everyone has heard the old adage "the more things change, the more they stay the same." Well, with JAX-RPC (the Java API for XML-based RPC), the adage comes true once more. JAX-RPC, while a cool way to expose Web services' functionality to Java as if they were local calls, is really just another instance of Remote Method Invocation (RMI).
For those unfamilar with RMI, a quick review is in order. Figure 1 shows a traditional development model, where client applications access an API to perform some function. Nothing unusual happens; the application is compiled against the API and at runtme, the OS directs the client call to the appropriate library and it's handled normally.
Figure 2 shows the RMI model, where the client still makes what appears to be a local call. Actually, the call is handled by a stub that looks like the API call, but in fact the stub redirects the call to a remote server that provides the service. The call is then made to a remote skeleton that makes the call on the remote object. The result of the call is then returned in a similar fashion.
Specifically, an RMI call works as follows:
- The client calls the stub, which was provided at compile time as if it were a normal library.
- The stub redirects the call to the appropriate server.
- The server, which was waiting for such events, catches the call and redirects it to a framework.
- The framework, which wraps the actual impementation of the service, then calls the service on behalf of the client.
- The framework returns the call to the server.
- The service, in turn, returns the information to the originating client stub.
- Finally, the client stub returns the information to the client application as if it were an everyday method call.
JAX-RPC, for all practical purposes, extends this model to Web services and, as we will see shortly, allows Java applications to call Web services as if they were local calls. In fact, JAX-RPC calls look very much like their RMI cousins. As shown in Figure 3, the JAX-RPC model is identical to the RPC model shown in Figure 2, except for the introduction of Web services. Of course, there is a single, incredibly important difference between JAX-RPC and historic RMI -- JAX-RPC can be used to access non-Java Web services!
JAX-RPC provides support for three different services:
- Server-side runtime environment for supporting JAX-RPC calls, specifically support for exposing services as Web services. Technically, this isn't a JAX-RPC mechanism, but rather a mechnanism for exposing something as a Web service.
- Client-side runtime services for indirecting client-side calls to a Web service using XML and SOAP.
- Compile-time enviroment for developing JAX-RPC-based services.
From a client perspective, JAX-RPC provides two specific mechanisms for invoking Web services:
- Traditional client-side method invocation, a la the RMI of old.
- Dynamic invocation, which provides support for calling previously unknown Web services by generating the call stack on the fly, rather then hard-coding method calls.
From a building blocks perspective, JAX-RPC provides two specific mechanisms for binding functionality to Web services:
- The ability to build a Web service from an interface description.
- The ability to link an implementation to a defined Web service.
In a nutshell, JAX-RPC provides the ability to generate WSDL from a Java interface and a Java interface from WSDL -- and, of course, the ability to generate the client-side stubs!
The spring release of the Java XML Pack contains Early Access Release 2 of JAX-RPC. While the JAX-RPC specification has not completed its review, you can download an early access edition. Additionally, BEA's WebLogic Server 7.0 beta includes support for JAX-RPC.
Pages: 1, 2