Spring Web Services Framework

org.springframework.ws.client.core
Class WebServiceTemplate

java.lang.Object
  extended by org.springframework.xml.transform.TransformerObjectSupport
      extended by org.springframework.ws.client.support.WebServiceAccessor
          extended by org.springframework.ws.client.core.WebServiceTemplate
All Implemented Interfaces:
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.

Since:
1.0.0
Author:
Arjen Poutsma

Field Summary
static String MESSAGE_TRACING_LOG_CATEGORY
          Log category to use for message tracing.
protected static Log receivedMessageTracingLogger
          Additional logger to use for received message tracing.
protected static Log sentMessageTracingLogger
          Additional logger to use for sent message tracing.
 
Fields inherited from class org.springframework.xml.transform.TransformerObjectSupport
logger
 
Constructor Summary
WebServiceTemplate()
          Creates a new WebServiceTemplate using default settings.
WebServiceTemplate(org.springframework.oxm.Marshaller marshaller)
          Creates a new WebServiceTemplate with the given marshaller.
WebServiceTemplate(org.springframework.oxm.Marshaller marshaller, org.springframework.oxm.Unmarshaller unmarshaller)
          Creates a new MarshallingMethodEndpointAdapter with the given marshaller and unmarshaller.
WebServiceTemplate(WebServiceMessageFactory messageFactory)
          Creates a new WebServiceTemplate based on the given message factory.
 
Method Summary
protected
<T> T
doSendAndReceive(MessageContext messageContext, WebServiceConnection connection, WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor)
          Sends and receives a MessageContext.
 String getDefaultUri()
          Returns the default URI to be used on operations that do not have a URI parameter.
 DestinationProvider getDestinationProvider()
          Returns the destination provider used on operations that do not have a URI parameter.
 FaultMessageResolver getFaultMessageResolver()
          Returns the fault message resolver for this template.
 ClientInterceptor[] getInterceptors()
          Returns the client interceptors to apply to all web service invocations made by this template.
 org.springframework.oxm.Marshaller getMarshaller()
          Returns the marshaller for this template.
 org.springframework.oxm.Unmarshaller getUnmarshaller()
          Returns the unmarshaller for this template.
protected  Object handleError(WebServiceConnection connection, WebServiceMessage request)
          Handles an error on the given connection.
protected  Object handleFault(WebServiceConnection connection, MessageContext messageContext)
          Handles an fault in the given response message.
protected  boolean hasError(WebServiceConnection connection, WebServiceMessage request)
          Determines whether the given connection or message context has an error.
protected  boolean hasFault(WebServiceConnection connection, WebServiceMessage response)
          Determines whether the given connection or message has a fault.
protected  void initDefaultStrategies()
          Initialize the default implementations for the template's strategies: SoapFaultMessageResolver, SaajSoapMessageFactory, and HttpUrlConnectionMessageSender.
 Object marshalSendAndReceive(Object requestPayload)
          Sends a web service message that contains the given payload, marshalled by the configured Marshaller.
 Object marshalSendAndReceive(Object requestPayload, WebServiceMessageCallback requestCallback)
          Sends a web service message that contains the given payload, marshalled by the configured Marshaller.
 Object marshalSendAndReceive(String uri, Object requestPayload)
          Sends a web service message that contains the given payload, marshalled by the configured Marshaller.
 Object marshalSendAndReceive(String uri, Object requestPayload, WebServiceMessageCallback requestCallback)
          Sends a web service message that contains the given payload, marshalled by the configured Marshaller.
 boolean sendAndReceive(String uri, WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback)
          Sends a web service message that can be manipulated with the given request callback, handling the response with a response callback.
<T> T
sendAndReceive(String uriString, WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor)
          Sends a web service message that can be manipulated with the given callback, reading the result with a WebServiceMessageExtractor.
 boolean sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageCallback responseCallback)
          Sends a web service message that can be manipulated with the given request callback, handling the response with a response callback.
<T> T
sendAndReceive(WebServiceMessageCallback requestCallback, WebServiceMessageExtractor<T> responseExtractor)
          Sends a web service message that can be manipulated with the given callback, reading the result with a WebServiceMessageExtractor.
<T> T
sendSourceAndReceive(Source requestPayload, SourceExtractor<T> responseExtractor)
          Sends a web service message that contains the given payload, reading the result with a SourceExtractor.
<T> T
sendSourceAndReceive(Source requestPayload, WebServiceMessageCallback requestCallback, SourceExtractor<T> responseExtractor)
          Sends a web service message that contains the given payload, reading the result with a SourceExtractor.
<T> T
sendSourceAndReceive(String uri, Source requestPayload, SourceExtractor<T> responseExtractor)
          Sends a web service message that contains the given payload, reading the result with a SourceExtractor.
<T> T
sendSourceAndReceive(String uri, Source requestPayload, WebServiceMessageCallback requestCallback, SourceExtractor<T> responseExtractor)
          Sends a web service message that contains the given payload, reading the result with a SourceExtractor.
 boolean sendSourceAndReceiveToResult(Source requestPayload, Result responseResult)
          Sends a web service message that contains the given payload.
 boolean sendSourceAndReceiveToResult(Source requestPayload, WebServiceMessageCallback requestCallback, Result responseResult)
          Sends a web service message that contains the given payload.
 boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, Result responseResult)
          Sends a web service message that contains the given payload.
 boolean sendSourceAndReceiveToResult(String uri, Source requestPayload, WebServiceMessageCallback requestCallback, Result responseResult)
          Sends a web service message that contains the given payload.
 void setCheckConnectionForError(boolean checkConnectionForError)
          Indicates whether the connection should be checked for error indicators (true), or whether these should be ignored (false).
 void setCheckConnectionForFault(boolean checkConnectionForFault)
          Indicates whether the connection should be checked for fault indicators (true), or whether we should rely on the message only (false).
 void setDefaultUri(String uri)
          Set the default URI to be used on operations that do not have a URI parameter.
 void setDestinationProvider(DestinationProvider destinationProvider)
          Set the destination provider URI to be used on operations that do not have a URI parameter.
 void setFaultMessageResolver(FaultMessageResolver faultMessageResolver)
          Sets the fault resolver for this template.
 void setInterceptors(ClientInterceptor[] interceptors)
          Sets the client interceptors to apply to all web service invocations made by this template.
 void setMarshaller(org.springframework.oxm.Marshaller marshaller)
          Sets the marshaller for this template.
 void setUnmarshaller(org.springframework.oxm.Unmarshaller unmarshaller)
          Sets the unmarshaller for this template.
 
Methods inherited from class org.springframework.ws.client.support.WebServiceAccessor
afterPropertiesSet, createConnection, getMessageFactory, getMessageSenders, setMessageFactory, setMessageSender, setMessageSenders
 
Methods inherited from class org.springframework.xml.transform.TransformerObjectSupport
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_TRACING_LOG_CATEGORY

public static final String MESSAGE_TRACING_LOG_CATEGORY
Log category to use for message tracing.

See Also:
Constant Field Values

sentMessageTracingLogger

protected static final Log sentMessageTracingLogger
Additional logger to use for sent message tracing.


receivedMessageTracingLogger

protected static final Log receivedMessageTracingLogger
Additional logger to use for received message tracing.

Constructor Detail

WebServiceTemplate

public WebServiceTemplate()
Creates a new WebServiceTemplate using default settings.


WebServiceTemplate

public WebServiceTemplate(WebServiceMessageFactory messageFactory)
Creates a new WebServiceTemplate based on the given message factory.

Parameters:
messageFactory - the message factory to use

WebServiceTemplate

public WebServiceTemplate(org.springframework.oxm.Marshaller marshaller)
Creates a new WebServiceTemplate with the given marshaller. If the given Marshaller also implements the Unmarshaller interface, it is used for both marshalling and unmarshalling. Otherwise, an exception is thrown.

Note that all Marshaller implementations in Spring also implement the Unmarshaller interface, so that you can safely use this constructor.

Parameters:
marshaller - object used as marshaller and unmarshaller
Throws:
IllegalArgumentException - when marshaller does not implement the Unmarshaller interface
Since:
2.0.3

WebServiceTemplate

public WebServiceTemplate(org.springframework.oxm.Marshaller marshaller,
                          org.springframework.oxm.Unmarshaller unmarshaller)
Creates a new MarshallingMethodEndpointAdapter with the given marshaller and unmarshaller.

Parameters:
marshaller - the marshaller to use
unmarshaller - the unmarshaller to use
Since:
2.0.3
Method Detail

getDefaultUri

public String getDefaultUri()
Returns the default URI to be used on operations that do not have a URI parameter.


setDefaultUri

public void setDefaultUri(String uri)
Set the default URI to be used on operations that do not have a URI parameter.

Typically, either this property is set, or setDestinationProvider(DestinationProvider), but not both.

See Also:
marshalSendAndReceive(Object), marshalSendAndReceive(Object,WebServiceMessageCallback), sendSourceAndReceiveToResult(Source,Result), sendSourceAndReceiveToResult(Source,WebServiceMessageCallback,Result), sendSourceAndReceive(Source,SourceExtractor), sendSourceAndReceive(Source,WebServiceMessageCallback,SourceExtractor), sendAndReceive(WebServiceMessageCallback,WebServiceMessageCallback)

getDestinationProvider

public DestinationProvider getDestinationProvider()
Returns the destination provider used on operations that do not have a URI parameter.


setDestinationProvider

public void setDestinationProvider(DestinationProvider destinationProvider)
Set the destination provider URI to be used on operations that do not have a URI parameter.

Typically, either this property is set, or setDefaultUri(String), but not both.

See Also:
marshalSendAndReceive(Object), marshalSendAndReceive(Object,WebServiceMessageCallback), sendSourceAndReceiveToResult(Source,Result), sendSourceAndReceiveToResult(Source,WebServiceMessageCallback,Result), sendSourceAndReceive(Source,SourceExtractor), sendSourceAndReceive(Source,WebServiceMessageCallback,SourceExtractor), sendAndReceive(WebServiceMessageCallback,WebServiceMessageCallback)

getMarshaller

public org.springframework.oxm.Marshaller getMarshaller()
Returns the marshaller for this template.


setMarshaller

public void setMarshaller(org.springframework.oxm.Marshaller marshaller)
Sets the marshaller for this template.


getUnmarshaller

public org.springframework.oxm.Unmarshaller getUnmarshaller()
Returns the unmarshaller for this template.


setUnmarshaller

public void setUnmarshaller(org.springframework.oxm.Unmarshaller unmarshaller)
Sets the unmarshaller for this template.


getFaultMessageResolver

public FaultMessageResolver getFaultMessageResolver()
Returns the fault message resolver for this template.


setFaultMessageResolver

public void setFaultMessageResolver(FaultMessageResolver faultMessageResolver)
Sets the fault resolver for this template. Default is the org.springframework.ws.soap.client.core.SoapFaultMessageResolver, SoapFaultMessageResolver, but may be set to null to disable fault handling.


setCheckConnectionForError

public void setCheckConnectionForError(boolean checkConnectionForError)
Indicates whether the connection should be checked for error indicators (true), or whether these should be ignored (false). The default is true.

When using an HTTP transport, this property defines whether to check the HTTP response status code is in the 2xx Successful range. Both the SOAP specification and the WS-I Basic Profile define that a Web service must return a "200 OK" or "202 Accepted" HTTP status code for a normal response. Setting this property to false allows this template to deal with non-conforming services.

See Also:
hasError(WebServiceConnection, WebServiceMessage), SOAP 1.1 specification, WS-I Basic Profile

setCheckConnectionForFault

public void setCheckConnectionForFault(boolean checkConnectionForFault)
Indicates whether the connection should be checked for fault indicators (true), or whether we should rely on the message only (false). The default is true.

When using an HTTP transport, this property defines whether to check the HTTP response status code for fault indicators. Both the SOAP specification and the WS-I Basic Profile define that a Web service must return a "500 Internal Server Error" HTTP status code if the response envelope is a Fault. Setting this property to false allows this template to deal with non-conforming services.

See Also:
hasFault(WebServiceConnection,WebServiceMessage), SOAP 1.1 specification, WS-I Basic Profile

getInterceptors

public ClientInterceptor[] getInterceptors()
Returns the client interceptors to apply to all web service invocations made by this template.

Returns:
array of endpoint interceptors, or null if none

setInterceptors

public final void setInterceptors(ClientInterceptor[] interceptors)
Sets the client interceptors to apply to all web service invocations made by this template.

Parameters:
interceptors - array of endpoint interceptors, or null if none

initDefaultStrategies

protected void initDefaultStrategies()
Initialize the default implementations for the template's strategies: SoapFaultMessageResolver, SaajSoapMessageFactory, and HttpUrlConnectionMessageSender.

Throws:
BeanInitializationException - in case of initalization errors
See Also:
setFaultMessageResolver(FaultMessageResolver), WebServiceAccessor.setMessageFactory(WebServiceMessageFactory), WebServiceAccessor.setMessageSender(WebServiceMessageSender)

marshalSendAndReceive

public Object marshalSendAndReceive(Object requestPayload)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, marshalled by the configured Marshaller. Returns the unmarshalled payload of the response message, if any.

This will only work with a default uri specified!

Specified by:
marshalSendAndReceive in interface WebServiceOperations
Parameters:
requestPayload - the object to marshal into the request message payload
Returns:
the unmarshalled payload of the response message, or null if no response is given
See Also:
setMarshaller(org.springframework.oxm.Marshaller), setUnmarshaller(org.springframework.oxm.Unmarshaller)

marshalSendAndReceive

public Object marshalSendAndReceive(String uri,
                                    Object requestPayload)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, marshalled by the configured Marshaller. Returns the unmarshalled payload of the response message, if any.

Specified by:
marshalSendAndReceive in interface WebServiceOperations
Parameters:
uri - the URI to send the message to
requestPayload - the object to marshal into the request message payload
Returns:
the unmarshalled payload of the response message, or null if no response is given
See Also:
setMarshaller(org.springframework.oxm.Marshaller), setUnmarshaller(org.springframework.oxm.Unmarshaller)

marshalSendAndReceive

public Object marshalSendAndReceive(Object requestPayload,
                                    WebServiceMessageCallback requestCallback)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, marshalled by the configured Marshaller. Returns the unmarshalled payload of the response message, if any. The given callback allows changing of the request message after the payload has been marshalled to it.

This will only work with a default uri specified!

Specified by:
marshalSendAndReceive in interface WebServiceOperations
Parameters:
requestPayload - the object to marshal into the request message payload
requestCallback - callback to change message, can be null
Returns:
the unmarshalled payload of the response message, or null if no response is given
See Also:
setMarshaller(org.springframework.oxm.Marshaller), setUnmarshaller(org.springframework.oxm.Unmarshaller)

marshalSendAndReceive

public Object marshalSendAndReceive(String uri,
                                    Object requestPayload,
                                    WebServiceMessageCallback requestCallback)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, marshalled by the configured Marshaller. Returns the unmarshalled payload of the response message, if any. The given callback allows changing of the request message after the payload has been marshalled to it.

Specified by:
marshalSendAndReceive in interface WebServiceOperations
Parameters:
uri - the URI to send the message to
requestPayload - the object to marshal into the request message payload
requestCallback - callback to change message, can be null
Returns:
the unmarshalled payload of the response message, or null if no response is given
See Also:
setMarshaller(org.springframework.oxm.Marshaller), setUnmarshaller(org.springframework.oxm.Unmarshaller)

sendSourceAndReceiveToResult

public boolean sendSourceAndReceiveToResult(Source requestPayload,
                                            Result responseResult)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload. Writes the response, if any, to the given Result.

This will only work with a default uri specified!

Specified by:
sendSourceAndReceiveToResult in interface WebServiceOperations
Parameters:
requestPayload - the payload of the request message
responseResult - the result to write the response payload to
Returns:
true if a response was received; false otherwise

sendSourceAndReceiveToResult

public boolean sendSourceAndReceiveToResult(String uri,
                                            Source requestPayload,
                                            Result responseResult)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload. Writes the response, if any, to the given Result.

Specified by:
sendSourceAndReceiveToResult in interface WebServiceOperations
Parameters:
uri - the URI to send the message to
requestPayload - the payload of the request message
responseResult - the result to write the response payload to
Returns:
true if a response was received; false otherwise

sendSourceAndReceiveToResult

public boolean sendSourceAndReceiveToResult(Source requestPayload,
                                            WebServiceMessageCallback requestCallback,
                                            Result responseResult)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload. Writes the response, if any, to the given Result.

The given callback allows changing of the request message after the payload has been written to it.

This will only work with a default uri specified!

Specified by:
sendSourceAndReceiveToResult in interface WebServiceOperations
Parameters:
requestPayload - the payload of the request message
requestCallback - callback to change message, can be null
responseResult - the result to write the response payload to
Returns:
true if a response was received; false otherwise

sendSourceAndReceiveToResult

public boolean sendSourceAndReceiveToResult(String uri,
                                            Source requestPayload,
                                            WebServiceMessageCallback requestCallback,
                                            Result responseResult)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload. Writes the response, if any, to the given Result.

The given callback allows changing of the request message after the payload has been written to it.

Specified by:
sendSourceAndReceiveToResult in interface WebServiceOperations
Parameters:
uri - the URI to send the message to
requestPayload - the payload of the request message
requestCallback - callback to change message, can be null
responseResult - the result to write the response payload to
Returns:
true if a response was received; false otherwise

sendSourceAndReceive

public <T> T sendSourceAndReceive(Source requestPayload,
                                  SourceExtractor<T> responseExtractor)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, reading the result with a SourceExtractor.

This will only work with a default uri specified!

Specified by:
sendSourceAndReceive in interface WebServiceOperations
Parameters:
requestPayload - the payload of the request message
responseExtractor - object that will extract results
Returns:
an arbitrary result object, as returned by the SourceExtractor

sendSourceAndReceive

public <T> T sendSourceAndReceive(String uri,
                                  Source requestPayload,
                                  SourceExtractor<T> responseExtractor)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, reading the result with a SourceExtractor.

Specified by:
sendSourceAndReceive in interface WebServiceOperations
Parameters:
uri - the URI to send the message to
requestPayload - the payload of the request message
responseExtractor - object that will extract results
Returns:
an arbitrary result object, as returned by the SourceExtractor

sendSourceAndReceive

public <T> T sendSourceAndReceive(Source requestPayload,
                                  WebServiceMessageCallback requestCallback,
                                  SourceExtractor<T> responseExtractor)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, reading the result with a SourceExtractor.

The given callback allows changing of the request message after the payload has been written to it.

This will only work with a default uri specified!

Specified by:
sendSourceAndReceive in interface WebServiceOperations
Parameters:
requestPayload - the payload of the request message
requestCallback - callback to change message, can be null
responseExtractor - object that will extract results
Returns:
an arbitrary result object, as returned by the SourceExtractor

sendSourceAndReceive

public <T> T sendSourceAndReceive(String uri,
                                  Source requestPayload,
                                  WebServiceMessageCallback requestCallback,
                                  SourceExtractor<T> responseExtractor)
Description copied from interface: WebServiceOperations
Sends a web service message that contains the given payload, reading the result with a SourceExtractor.

The given callback allows changing of the request message after the payload has been written to it.

Specified by:
sendSourceAndReceive in interface WebServiceOperations
Parameters:
uri - the URI to send the message to
requestPayload - the payload of the request message
requestCallback - callback to change message, can be null
responseExtractor - object that will extract results
Returns:
an arbitrary result object, as returned by the SourceExtractor

sendAndReceive

public boolean sendAndReceive(WebServiceMessageCallback requestCallback,
                              WebServiceMessageCallback responseCallback)
Description copied from interface: WebServiceOperations
Sends a web service message that can be manipulated with the given request callback, handling the response with a response callback.

This will only work with a default uri specified!

Specified by:
sendAndReceive in interface WebServiceOperations
Parameters:
requestCallback - the callback to be used for manipulating the request message
responseCallback - the callback to be used for manipulating the response message
Returns:
true if a response was received; false otherwise

sendAndReceive

public boolean sendAndReceive(String uri,
                              WebServiceMessageCallback requestCallback,
                              WebServiceMessageCallback responseCallback)
Description copied from interface: WebServiceOperations
Sends a web service message that can be manipulated with the given request callback, handling the response with a response callback.

Specified by:
sendAndReceive in interface WebServiceOperations
Parameters:
uri - the URI to send the message to
requestCallback - the callback to be used for manipulating the request message
responseCallback - the callback to be used for manipulating the response message
Returns:
true if a response was received; false otherwise

sendAndReceive

public <T> T sendAndReceive(WebServiceMessageCallback requestCallback,
                            WebServiceMessageExtractor<T> responseExtractor)
Description copied from interface: WebServiceOperations
Sends a web service message that can be manipulated with the given callback, reading the result with a WebServiceMessageExtractor.

This will only work with a default uri specified!

Specified by:
sendAndReceive in interface WebServiceOperations
Parameters:
requestCallback - the requestCallback to be used for manipulating the request message
responseExtractor - object that will extract results
Returns:
an arbitrary result object, as returned by the WebServiceMessageExtractor

sendAndReceive

public <T> T sendAndReceive(String uriString,
                            WebServiceMessageCallback requestCallback,
                            WebServiceMessageExtractor<T> responseExtractor)
Description copied from interface: WebServiceOperations
Sends a web service message that can be manipulated with the given callback, reading the result with a WebServiceMessageExtractor.

Specified by:
sendAndReceive in interface WebServiceOperations
Parameters:
uriString - the URI to send the message to
requestCallback - the requestCallback to be used for manipulating the request message
responseExtractor - object that will extract results
Returns:
an arbitrary result object, as returned by the WebServiceMessageExtractor

doSendAndReceive

protected <T> T doSendAndReceive(MessageContext messageContext,
                                 WebServiceConnection connection,
                                 WebServiceMessageCallback requestCallback,
                                 WebServiceMessageExtractor<T> responseExtractor)
                      throws IOException
Sends and receives a MessageContext. Sends the request message, and received to the repsonse message. Invocates the defined interceptors as part of the process.

Parameters:
messageContext - the message context
connection - the connection to use
requestCallback - the requestCallback to be used for manipulating the request message
responseExtractor - object that will extract results
Returns:
an arbitrary result object, as returned by the WebServiceMessageExtractor
Throws:
WebServiceClientException - if there is a problem sending or receiving the message
IOException - in case of I/O errors

hasError

protected boolean hasError(WebServiceConnection connection,
                           WebServiceMessage request)
                    throws IOException
Determines whether the given connection or message context has an error.

This implementation checks the connection first. If it indicates an error, it makes sure that it is not a fault.

Parameters:
connection - the connection (possibly a FaultAwareWebServiceConnection
request - the response message (possibly a FaultAwareWebServiceMessage
Returns:
true if the connection has an error; false otherwise
Throws:
IOException - in case of I/O errors

handleError

protected Object handleError(WebServiceConnection connection,
                             WebServiceMessage request)
                      throws IOException
Handles an error on the given connection. The default implementation throws a WebServiceTransportException.

Parameters:
connection - the erroneous connection
request - the corresponding request message
Returns:
the object to be returned from sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor), if any
Throws:
IOException

hasFault

protected boolean hasFault(WebServiceConnection connection,
                           WebServiceMessage response)
                    throws IOException
Determines whether the given connection or message has a fault.

This implementation checks the connection if the checkConnectionForFault property is true, and defaults to the message otherwise.

Parameters:
connection - the connection (possibly a FaultAwareWebServiceConnection
response - the response message (possibly a FaultAwareWebServiceMessage
Returns:
true if either the connection or the message has a fault; false otherwise
Throws:
IOException - in case of I/O errors

handleFault

protected Object handleFault(WebServiceConnection connection,
                             MessageContext messageContext)
                      throws IOException
Handles an fault in the given response message. The default implementation invokes the fault resolver if registered, or invokes handleError(WebServiceConnection, WebServiceMessage) otherwise.

Parameters:
connection - the faulty connection
messageContext - the message context
Returns:
the object to be returned from sendAndReceive(String,WebServiceMessageCallback, WebServiceMessageExtractor), if any
Throws:
IOException

Spring Web Services Framework

Copyright © 2005-2013 The Spring Web Services Framework. All Rights Reserved.