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

AxiomContentHandler should empty the response body before adding the transformation result

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.3
    • Fix Version/s: 1.5 M2, 1.0.4
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Java 5 (build 1.5.0_13-b05-241) + Axiom 1.2.5

      Description

      AxiomContentHandler append the result of the XSLT transformation without first emptying the response body. The resulting SOAP response ends up with 2 body child elements : the original (untransformed) endpoint response and the transformation result.

      The following patch fixes the problem :

      — ../spring-ws-1.0.3/modules/core/src/main/java/org/springframework/ws/soap/axiom/AxiomContentHandler.java 2007-12-21 16:26:32.000000000 +0100
      +++ AxiomContentHandler.java 2008-01-08 15:14:41.000000000 +0100
      @@ -16,6 +16,7 @@

      package org.springframework.ws.soap.axiom;

      +import org.apache.axiom.om.OMNode;
      import org.apache.axiom.om.OMElement;
      import org.apache.axiom.om.impl.builder.SAXOMBuilder;
      import org.springframework.util.Assert;
      @@ -39,6 +40,15 @@

      public void endDocument() throws SAXException {
      super.endDocument();
      +
      + // Remove original (i.e. source) response body.
      + OMNode child = null;
      + while ((child = parentElement.getFirstOMChild()) != null)
      +

      { + child.detach(); + }

      +
      + // Set result (i.e. transformed) response body.
      parentElement.addChild(super.getRootElement());
      }
      }

        Activity

        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        I don't think adding this functionality to the ContentHandler is the right way to fix this. The ContentHandler is responsible for adding Axiom nodes to a OMContainer, and nothing more. It is used by getPayloadResult(), for instance.

        Instead, code that uses the AxiomContentHandler (AxiomSoapBody, for instance) should remove the children before using the handler. This is the approach taken in the SAAJ code (SaajSoapBody), and the Axiom code should be similar.

        Thanks for finding the bug, though!

        Show
        arjen.poutsma Arjen Poutsma added a comment - I don't think adding this functionality to the ContentHandler is the right way to fix this. The ContentHandler is responsible for adding Axiom nodes to a OMContainer, and nothing more. It is used by getPayloadResult(), for instance. Instead, code that uses the AxiomContentHandler (AxiomSoapBody, for instance) should remove the children before using the handler. This is the approach taken in the SAAJ code (SaajSoapBody), and the Axiom code should be similar. Thanks for finding the bug, though!
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Reopening issues for 1.0.4

        Show
        arjen.poutsma Arjen Poutsma added a comment - Reopening issues for 1.0.4
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Fixed in 1.0 branch.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Fixed in 1.0 branch.
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing issues for 1.0.4

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

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            lbihanic Laurent Bihanic
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: