Developing an Apache SOAP client

 

Develop a client that has a Web Services Description Language (WSDL) file or service implementation.

Creating clients to access the Simple Object Access Protocol (SOAP) services published in WebSphere Application Server is a straightforward 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 Java documentation.To create a client that interacts with a SOAP Remote Procedure Call (RPC) service:

 

  1. Obtain the interface description of the SOAP service. This description provides the signatures of the methods that you want to invoke. One can either look at a Web Services Description Language (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 Uniform Resource Identifier (URI) in the call object using the setTargetObjectURI() method.

    Pass the Uniform Resource Name (URN), 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 invoke() method and retrieve the response object. Remember the RPC call is synchronous, so it can 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.

 

What to do next

Interacting with a document-oriented SOAP service requires you to use lower-level Apache SOAP API calls. You must first construct an envelope object containing 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 can 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 conf configuration file.


Securing Apache SOAP Web services

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.