12.3.1. RPC or Messaging?
Your first task is actually not code-related but design-related. You
need to determine if you want an RPC service or a messaging one. The
first, RPC, is something you should be pretty familiar with after the
last chapter. A client invokes a remote procedure on a server
somewhere, and then gets some sort of response. In this scenario,
SOAP is simply acting as a more extensible XML-RPC system, allowing
better error handling and passing of complex types across the
network. This is a concept you should already understand, and because
it turns out that RPC systems are simple to write in SOAP, I'll
start off there. This chapter describes how to write an RPC service,
and then an RPC client, and put the system in action.
The second style of SOAP processing is message-based. Instead of
invoking remote procedures, it provides for transfer of information.
As you can imagine, this is pretty powerful, and doesn't depend
on a client knowing about a particular method on some server. It also
models distributed systems more closely, allowing packets of data
(packet in the figurative sense, not in the network sense) to be
passed around, keeping various systems aware of what other systems
are doing. It is also more complicated than the simpler RPC-style
programming, so I'll cover it in the next chapter with other
business-to-business details after you're well grounded in
SOAP-RPC programming.
Like most design issues, the actual process of making this decision
is left up to you. Look at your application and determine exactly
what you want SOAP to do for you. If you have a server and a set of
clients that just need to perform tasks remotely, then RPC is
probably well suited for your needs. However, in larger systems that
are exchanging data rather than performing specific business
functions on request, SOAP's messaging capabilities may be a
better match.