Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-412

PayloadTransformingInterceptor does not work with a DomPoxMessage - the transformation clears the document

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.4
    • Fix Version/s: 1.5.5
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Weblogic 9.2.2, Java 1.5_10

      Description

      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

        Issue Links

          Activity

          Hide
          arjen.poutsma Arjen Poutsma added a comment - - edited

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

          Show
          arjen.poutsma Arjen Poutsma added a comment - - edited Done, transforming to a intermediate buffer now. This might be slower, but at least it works for all WebServiceMessage implementations.
          Hide
          arjen.poutsma Arjen Poutsma added a comment -

          Closing old issues

          Show
          arjen.poutsma Arjen Poutsma added a comment - Closing old issues

            People

            • Assignee:
              arjen.poutsma Arjen Poutsma
              Reporter:
              mengugu Guillaume Menguy
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: