Class PayloadTransformingInterceptor

java.lang.Object
org.springframework.xml.transform.TransformerObjectSupport
org.springframework.ws.server.endpoint.interceptor.PayloadTransformingInterceptor
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, EndpointInterceptor

public class PayloadTransformingInterceptor extends TransformerObjectSupport implements EndpointInterceptor, org.springframework.beans.factory.InitializingBean
Interceptor that transforms the payload of WebServiceMessages using XSLT stylesheet. Allows for seperate stylesheets for request and response. This interceptor is especially useful when supporting with multiple version of a Web service: you can transform the older message format to the new format.

The stylesheets to use can be set using the requestXslt and responseXslt properties. Both of these are optional: if not set, the message is simply not transformed. Setting one of the two is required, though.

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

    • PayloadTransformingInterceptor

      public PayloadTransformingInterceptor()
  • Method Details

    • setRequestXslt

      public void setRequestXslt(org.springframework.core.io.Resource requestXslt)
      Sets the XSLT stylesheet to use for transforming incoming request.
    • setResponseXslt

      public void setResponseXslt(org.springframework.core.io.Resource responseXslt)
      Sets the XSLT stylesheet to use for transforming outgoing responses.
    • handleRequest

      public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception
      Transforms the request message in the given message context using a provided stylesheet. Transformation only occurs if the requestXslt has been set.
      Specified by:
      handleRequest in interface EndpointInterceptor
      Parameters:
      messageContext - the message context
      endpoint - chosen endpoint to invoke
      Returns:
      always returns true
      Throws:
      Exception - in case of errors
      See Also:
    • handleResponse

      public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception
      Transforms the response message in the given message context using a stylesheet. Transformation only occurs if the responseXslt has been set.
      Specified by:
      handleResponse in interface EndpointInterceptor
      Parameters:
      messageContext - the message context
      endpoint - chosen endpoint to invoke
      Returns:
      always returns true
      Throws:
      Exception - in case of errors
      See Also:
    • handleFault

      public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception
      Does nothing by default. Faults are not transformed.
      Specified by:
      handleFault in interface EndpointInterceptor
      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

      public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex)
      Does nothing by default.
      Specified by:
      afterCompletion in interface EndpointInterceptor
      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
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception