[SWS-412] PayloadTransformingInterceptor does not work with a DomPoxMessage - the transformation clears the document Created: 10/Aug/08  Updated: 04/May/12  Resolved: 02/Sep/08

Status: Closed
Project: Spring Web Services
Component/s: Core
Affects Version/s: 1.5.4
Fix Version/s: 1.5.5

Type: Bug Priority: Major
Reporter: Guillaume Menguy Assignee: Arjen Poutsma
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Weblogic 9.2.2, Java 1.5_10

Issue Links:
is related to SWS-248 DomPoxMessage not clearing DOM on set... Closed


This bug is related to SWS-248

Emptying the Document in the method getPayloadResult() of the DomPoxMessage makes the transformation in the PayloadTransformingInterceptor impossible.

PayloadTransformingInterceptor source code 1.5.4

80 public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
81 if (requestTemplates != null)

{ 82 WebServiceMessage request = messageContext.getRequest(); 83 Transformer transformer = requestTemplates.newTransformer(); 84 transformer.transform(request.getPayloadSource(), request.getPayloadResult()); 85 logger.debug("Request message transformed"); 86 }

87 return true;
88 }

Line 84, before the transform() method is called, the 2nd argument evaluation clears the document inside the DomPoxMessage, so the DOMSource created by calling the 1st argument wraps now an empty document, the transformation returns always an empty XML.

See my small test :
public static void main(String[] args) throws IOException, TransformerFactoryConfigurationError, TransformerException

{ String content = "<element xmlns=\"http://www.springframework.org/spring-ws\" />"; byte[] bytes = content.getBytes("UTF-8"); InputStream input = new ByteArrayInputStream(bytes); DomPoxMessageFactory factory = new DomPoxMessageFactory(); DomPoxMessage domPoxMsg = (DomPoxMessage) factory.createWebServiceMessage(input); Result result = new StreamResult(System.out); Transformer t = TransformerFactory.newInstance().newTransformer(); System.out.println("1. Transformation to System.out :"); t.transform(domPoxMsg.getPayloadSource(), result); System.out.println("\n\n"); System.out.println("2. Transformation to message itself as Result (=interceptor)"); t.transform(domPoxMsg.getPayloadSource(), domPoxMsg.getPayloadResult()); System.out.println("\n\n"); System.out.println("3. Transformation to System.out :"); t.transform(domPoxMsg.getPayloadSource(), result); }

The solution may be to add an intermediate transformation ( a simple StreamResult) but as it is working for other WebServiceMessage implementation ( SOAP ) it could be too heavy ...

Note also that a testPayLoadInterceptor() could be added in DomPoxMessageTest

Comment by Arjen Poutsma [ 02/Sep/08 ]

Done, transforming to a intermediate buffer now. This might be slower, but at least it works for all WebServiceMessage implementations.

Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Thu Mar 21 22:13:34 UTC 2019 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.