Spring Web Services Framework

org.springframework.ws.server.endpoint.interceptor
Class PayloadTransformingInterceptor

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

public class PayloadTransformingInterceptor
extends TransformerObjectSupport
implements EndpointInterceptor, 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:
setRequestXslt(org.springframework.core.io.Resource), setResponseXslt(org.springframework.core.io.Resource)

Constructor Summary
PayloadTransformingInterceptor()
           
 
Method Summary
 void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex)
          Does nothing by default.
 void afterPropertiesSet()
           
 boolean handleFault(MessageContext messageContext, Object endpoint)
          Does nothing by default.
 boolean handleRequest(MessageContext messageContext, Object endpoint)
          Transforms the request message in the given message context using a provided stylesheet.
 boolean handleResponse(MessageContext messageContext, Object endpoint)
          Transforms the response message in the given message context using a stylesheet.
 void setRequestXslt(Resource requestXslt)
          Sets the XSLT stylesheet to use for transforming incoming request.
 void setResponseXslt(Resource responseXslt)
          Sets the XSLT stylesheet to use for transforming outgoing responses.
 
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
 

Constructor Detail

PayloadTransformingInterceptor

public PayloadTransformingInterceptor()
Method Detail

setRequestXslt

public void setRequestXslt(Resource requestXslt)
Sets the XSLT stylesheet to use for transforming incoming request.


setResponseXslt

public void setResponseXslt(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:
setRequestXslt(org.springframework.core.io.Resource)

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:
setResponseXslt(org.springframework.core.io.Resource)

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 InitializingBean
Throws:
Exception

Spring Web Services Framework

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