InfoCenter Home >
4: Developing applications >
4.8: Web services - an overview >
4.8.1: Web services components >
4.8.1.2: SOAP support >
4.8.1.2.2: Building a SOAP client

4.8.1.2.2: Building a SOAP client

Creating clients to access the SOAP services published in WebSphere Application Server is a straightfoward process. The Apache SOAP implementation, integrated with WebSphere Application Server, contains a client API to assist in SOAP client application development.

The SOAP API documentation is available in WebSphere Application Server's javadoc.

These are the steps for creating a client that interacts with a SOAP RPC service:

  1. Obtain the interface description of the SOAP service

    This provides you with the signatures of the methods that you wish 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) 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 in the "Call" object using the setMethodName() method

    This method must be one of the methods exposed by the service located at the URN from the previous step.

  5. Create the necessary "Parameter" objects for the RPC call and then 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. Execute the "Call" object's invoke() method and retrieve the "Response" object

    Remember the RPC call is synchronous, so it may take some time to complete.

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

    While 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 which contains the contents of the message (including the body and any headers) that you wish to send. Then create a "Message" object where you invoke the send() method to perform the actual transmission.

To create a secure SOAP service, do the following:

  1. Create a simple object
  2. Define an envelope editor
  3. Specify a pluggable envelope editor
  4. Define the transports

Your code may look like the following example:

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."

See article Securing SOAP services for more information on creating secure Web services.

See article 4.8.1.2.2.1: Accessing enterprise beans through SOAP for information on calling an EJB service.

Since the SOAP API is a standard for Web services, any clients that you create to access the WebSphere Application Server SOAP services can also run in different implementations.

See the related information links for an enablement scenario.

Go to previous article: SOAP samples Go to next article: Accessing enterprise beans  through SOAP

 

 
Go to previous article: SOAP samples Go to next article: Accessing enterprise beans  through SOAP