NonStop SOAP for Java User's Manual

Using the SOAP Client APIs
NonStop SOAP for Java User’s Manual523860-001
6-2
Interacting with Stateful Services
This method must be one of the methods exposed by the service identified by the
URN given in the previous step.
6. Create any Parameter objects necessary for the RPC call and set them into the
Call object using the setParams(...) method.
Verify that you have the same number of parameters that have the same types as
the service is expecting. Also make sure that there are registered serializers and
deserializers for the objects which you will be transmitting/receiving. (See Step 2.)
7. Execute the Call object's invoke(...) method and capture the Response object
which is returned from invoke(...).
The invoke(...) method takes in two parameters, the first is a URL which identifies
the endpoint at which the service resides (i.e.
http://localhost/soap/servlet/rpcrouter) and the second is the value
to be placed into the SOAPAction header. Remember that the RPC call is
synchronous, and so may take a while to complete.
8. Check the Response object to see if a fault was generated using the
generatedFault() method.
9. If a fault was returned, retrieve it using the getFault(...) method, otherwise extract
any result or returned parameters using the getReturnValue() and getParams()
methods respectively.
While most of the providers will only return a result, if you have created your own
provider (or obtained one from somewhere else,) it may also return output
parameters.
Because SOAP is a standard, you should be able to use the clients that you create
with the SOAP APIs to access services running on a different implementations.
Interacting with Stateful Services
Services may be stateful—that is, once an interaction is started with a service, a series
of calls to it may interdepend on each other.
Apache SOAP supports authoring stateful services (by deploying with a lifecycle of
session) as well as calling stateful services. However, session support is only available
for HTTP. HTTP session maintenance is on by default. What that means is that if a
service you are talking to using HTTP sets the appropriate HTTP cookies to maintain
the session, those will be copied and stored in the "call" object used to invoke the
service. If another call is made using the same call object, that cookie will be sent back
to the server, therefore maintaining the session. Thus, all you have to do is ensure that
a single instance of a call object is used across all the calls that you wish to make over
the same HTTP session.