Build a SOAP client

The Apache SOAP implementation, integrated with WebSphere Application Server - Express, contains a client API to assist in SOAP client application development. Because the SOAP API is a standard for Web services, any clients that you create to access the WebSphere Application Server - Express SOAP services can also run in different implementations.

The steps for creating a client that interacts with a SOAP Remote Procedure Call (RPC) service include:

  1. Obtain the interface description of the SOAP service
    This provides you with the signatures of the methods that you want to invoke. You can either look at a WSDL file for the service, or view the service itself to see its implementation.
  2. Create the Call object
    The SOAP Call object is the main interface to the underlying SOAP RPC code.
  3. Set the target URI (Uniform Resource Identifier)
    You do this in the Call object using the setTargetObjectURI() method. Pass the URN (Uniform Resource Name, a type of URI), that the service uses for its identifier, in the deployment descriptor.
  4. Set the method name that you want to invoke
    You do this in the Call object using the setMethodName() method. This method must be one of the methods published by the service located at the URN from the previous step.
  5. Create the necessary Parameter objects for the RPC call
    Once you have created the Parameter objects, set them in the Call object using the setParams() method. Ensure you have the same number and same type of parameters as those required by the service.
  6. Run the Call object's invoke() method and retrieve the Response object

    Note: The RPC call is synchronous, so it might take some time to complete.

  7. Validate Response object
    Check the response for a fault using the getFault() method, and then extract any results or returned parameters.

    Note: Although most of the providers only return a result, the DB2 stored procedure provider can also return output parameters.

Interacting with a document oriented SOAP service requires you to use lower level Apache SOAP API calls. You must first construct an Envelope object that contains the contents of the message (including the body and any headers) that you want to send. Then create a Message object in which you invoke the send() method to perform the actual transmission.

Creating a secure SOAP service

To create a secure SOAP service, perform these steps:
  1. Create a simple object.
  2. Define an envelope editor.
  3. Specify a pluggable envelope editor.
  4. Define the transports.

For more information about the envelope editor, see Envelope object.

Your code might look like this example:

Note: For legal information about this code example, see the Code example disclaimer.

EnvelopeEditor editor= new PluggableEnvelopeEditor(new InputSource(conf), home);
SOAPTransport transport = new FilterTransport(editor, new SOAPHTTPConnection());
call.setSOAPTransport(transport);

The characteristics of the secure session are specified by the configuration file, conf.