15.1 RPC
The core of all web services is
the ability for code on different machines to interact. There are as
many protocols, APIs, and solutions available for this task as there
are developers, but remote procedure calls are probably the most
traditional approach to the problem.
15.1.1 RPC Basics
A brief
discussion of the remote procedure call (RPC) is in order.
Object-oriented developers work with code such as that shown here:
Window myWindow = new Window( );
myWindow.setTitle("Hello");
You'll notice that the details of how to actually
set a window title are completely hidden from the developer. Not just
obvious details (such as the code for drawing the graphics) are
hidden here, but runtime details (such as how the methods are bound
to the object or how memory is allocated) are abstracted away. The
details are typically a combination of runtime code, compilers,
linkers, and other tools.
|
The idea that a local object is as easily accessible as a remote
object has never been verified, which makes a lot of the hype
surrounding RPC irrelevant for client applications. Except in highly
controlled production server environments, networks tend to be
available in a spotty fashion, and the introduction of wireless
devices makes it just that much worse. In the long run, perhaps in my
lifetime, I'll see networks that are fast and
reliable enough for me to trust as much as a local resource, but
probably not. This is partly why asynchronous messaging is so
important梑ut then again, writing both the user interface and
the actual code for asynchronous RPC-based applications, including
web services, is also complicated.
|
The basic idea behind RPC is that a developer ought to be able to
work with a remote object as naturally as with a local object:
Window myWindow = RemoteWindowServer.getWindow( );
myWindow.setTitle("Hello");
In this example, a window is created and runs on a remote server, and
all the standard interfaces that one would expect are now available,
except now the actual drawing of the window occurs on the remote
server. The details of how the text string
"Hello" is sent across the network
are abstracted away from the developer.
15.1.2 Java and RPC
Remote Method
Invocation (RMI) is the built-in Java implementation of an RPC
mechanism. RMI works well, but it requires some setup and
configuration, and, perhaps most importantly, it's a
very Java-specific way of performing RPC. The code that you write and
expose as RMI services is readily accessible only from another Java
application.
Recently, CORBA was positioned as the next big thing
in RPC mechanisms, but it suffered from its complexity. In
particular, a strong emphasis was placed on making CORBA a superset
of several different languages, including C++ and other languages
such as Pascal. CORBA bindings are included in the standard JDK
distribution, but they have never seen the kind of popularity that
its supporters would like.
|