Class WebServiceTemplate

All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, WebServiceOperations

public class WebServiceTemplate extends WebServiceAccessor implements WebServiceOperations
The central class for client-side Web services. It provides a message-driven approach to sending and receiving WebServiceMessage instances.

Code using this class need only implement callback interfaces, provide Source objects to read data from, or use the pluggable Marshaller support. For invoking the marshalling methods, the marshaller and unmarshaller properties must be set.

This template uses a SoapFaultMessageResolver to handle fault response messages. Another FaultMessageResolver can be defined with with faultMessageResolver property. If this property is set to null, no fault resolving is performed.

This template uses the following algorithm for sending and receiving.

  1. Call createConnection().
  2. Call createWebServiceMessage() on the registered message factory to create a request message.
  3. Invoke doWithMessage() on the request callback, if any. This step stores content in the request message, based on Source, marshalling, etc.
  4. Invoke handleRequest() on the registered interceptors. Interceptors are executed in order. If any of the interceptors creates a response message in the message context, skip to step 7.
  5. Call send() on the connection.
  6. Call hasError() to check if the connection has an error. For an HTTP transport, a status code other than 2xx indicates an error. However, since a status code of 500 can also indicate a SOAP fault, the template verifies whether the error is not a fault.
  7. Invoke receive on the connection to read the response message, if any.
  8. Call to close on the connection.
Arjen Poutsma