Interface EndpointInterceptor

All Known Subinterfaces:
SmartEndpointInterceptor, SmartSoapEndpointInterceptor, SoapEndpointInterceptor
All Known Implementing Classes:
AbstractFaultCreatingValidatingInterceptor, AbstractLoggingInterceptor, AbstractValidatingInterceptor, AbstractWsSecurityInterceptor, DelegatingSmartEndpointInterceptor, DelegatingSmartSoapEndpointInterceptor, EndpointInterceptorAdapter, PayloadLoggingInterceptor, PayloadRootSmartSoapEndpointInterceptor, PayloadTransformingInterceptor, PayloadValidatingInterceptor, SoapActionSmartEndpointInterceptor, SoapEnvelopeLoggingInterceptor, Wss4jSecurityInterceptor

public interface EndpointInterceptor
Workflow interface that allows for customized endpoint invocation chains. Applications can register any number of existing or custom interceptors for certain groups of endpoints, to add common preprocessing behavior without needing to modify each endpoint implementation.

An EndpointInterceptor gets called before the appropriate EndpointAdapter triggers the invocation of the endpoint itself. This mechanism can be used for a large field of preprocessing aspects, e.g. for authorization checks, or message header checks. Its main purpose is to allow for factoring out repetitive endpoint code.

Typically an interceptor chain is defined per EndpointMapping bean, sharing its granularity. To be able to apply a certain interceptor chain to a group of handlers, one needs to map the desired handlers via one EndpointMapping bean. The interceptors themselves are defined as beans in the application context, referenced by the mapping bean definition via its interceptors property (in XML: a <list> of <ref>).

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
  • Method Details

    • handleRequest

      boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception
      Processes the incoming request message. Called after EndpointMapping determined an appropriate endpoint object, but before EndpointAdapter invokes the endpoint.

      MessageDispatcher processes an endpoint in an invocation chain, consisting of any number of interceptors, with the endpoint itself at the end. With this method, each interceptor can decide to abort the chain, typically creating a custom response.

      Parameters:
      messageContext - contains the incoming request message
      endpoint - chosen endpoint to invoke
      Returns:
      true to continue processing of the request interceptor chain; false to indicate blocking of the request endpoint chain, without invoking the endpoint
      Throws:
      Exception - in case of errors
      See Also:
    • handleResponse

      boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception
      Processes the outgoing response message. Called after EndpointAdapter actually invoked the endpoint. Can manipulate the response, if any, by adding new headers, etc.

      MessageDispatcher processes an endpoint in an invocation chain, consisting of any number of interceptors, with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting applied in inverse order of the execution chain.

      Note: Will only be called if this interceptor's handleRequest(org.springframework.ws.context.MessageContext, java.lang.Object) method has successfully completed.

      Parameters:
      messageContext - contains both request and response messages
      endpoint - chosen endpoint to invoke
      Returns:
      true to continue processing of the response interceptor chain; false to indicate blocking of the response endpoint chain.
      Throws:
      Exception - in case of errors
      See Also:
    • handleFault

      boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception
      Processes the outgoing response fault. Called after EndpointAdapter actually invoked the endpoint. Can manipulate the response, if any, by adding new headers, etc.

      MessageDispatcher processes an endpoint in an invocation chain, consisting of any number of interceptors, with the endpoint itself at the end. With this method, each interceptor can post-process an invocation, getting applied in inverse order of the execution chain.

      Note: Will only be called if this interceptor's handleRequest(org.springframework.ws.context.MessageContext, java.lang.Object) method has successfully completed.

      Parameters:
      messageContext - contains both request and response messages, the response should contains a Fault
      endpoint - chosen endpoint to invoke
      Returns:
      true to continue processing of the response interceptor chain; false to indicate blocking of the response handler chain.
      Throws:
      Exception
    • afterCompletion

      void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception
      Callback after completion of request and response (fault) processing. Will be called on any outcome of endpoint invocation, thus allows for proper resource cleanup.

      Note: Will only be called if this interceptor's handleRequest(org.springframework.ws.context.MessageContext, java.lang.Object) method has successfully completed.

      As with the handleResponse(org.springframework.ws.context.MessageContext, java.lang.Object) method, the method will be invoked on each interceptor in the chain in reverse order, so the first interceptor will be the last to be invoked.

      Parameters:
      messageContext - contains both request and response messages, the response should contains a Fault
      endpoint - chosen endpoint to invoke
      ex - exception thrown on handler execution, if any
      Throws:
      Exception - in case of errors
      Since:
      2.0.2