Writing RPC Services
Writing an RPC-based SOAP service is a very
trivial undertaking, and really only involves
the following two basic steps:
- Create a code artifact which is supported
by one of the Apache SOAP providers; either a standard Java class (including
Java Beans,) an EJB, or a BSF supported script.
The code artifact does not have to know anything
about Apache SOAP, as you will simply be
exposing either a method or a script function
that exists within the artifact. For example,
if you create a Java class that has a method
called add(), then you could expose that
method as a SOAP service. Multiple methods
may be exposed for a single service, as is
described in the next section.
Note that parameters to your method/function
must be serializable by SOAP, and so must
exist within the SOAP mapping registry. For information on creating type mappings,
look here.
- Create an Apache SOAP deployment descriptor
for your service. The deployment descriptor provides the implementation
with the information necessary to handle
requests for an offered service. For a Java
service implementation, this will include
such information as the name of the class
which is providing the implementation, as
well as the name of the methods which are
to be exposed. More information about the
deployment descriptors may be found here.
In a Java based service implementation, you
may throw a SOAPException to indicate that
some error has occurred when processing the
request. Throwing a SOAPException(FAULT_CODE_CLIENT,
...) will allow your service implementation
to indicate that the failure was due to a
client error, whereas throwing a SOAPException(FAULT_CODE_SERVER,
...) will indicate that your service implementation
was at fault. (If you throw any other type
of exception, the server will catch it, and
will pass it on as a SOAPException(FAULT_CODE_SERVER,
...)) See the SOAP v1.1 specification for
more information on SOAP Faults.
Last updated 5/18/2001 by Bill Nagy <nagy@watson.ibm.com>.