Author: veithen Date: Sat Dec 6 11:12:28 2008 New Revision: 724029 URL: http://svn.apache.org/viewvc?rev=724029&view=rev Log: * StAXOMBuilder didn't update lastNode after constructing a comment node. Under some circumstances, this caused the comment node to be discarded (as described in WSCOMMONS-115). Fixed this issue. * StAXSOAPModelBuilder didn't handle properly the case where the SOAP envelope is preceded by a comment (or any other node). This issue was hidden by the issue in StAXOMBuilder described above. Note that having a SOAP envelope preceded by a comment is rather unusual, but is the case for some of the messages used in the test cases (where the comment is the copyright notice). Fixed the code so that this situation is handled correctly.
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=724029&r1=724028&r2=724029&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java Sat Dec 6 11:12:28 2008 @@ -230,7 +230,7 @@ lastNode = createOMText(XMLStreamConstants.SPACE); break; case XMLStreamConstants.COMMENT: - createComment(); + lastNode = createComment(); break; case XMLStreamConstants.DTD: createDTD(); Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java?rev=724029&r1=724028&r2=724029&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java Sat Dec 6 11:12:28 2008 @@ -20,6 +20,7 @@ package org.apache.axiom.soap.impl.builder; import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMContainer; import org.apache.axiom.om.OMDocument; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; @@ -209,11 +210,22 @@ node = constructNode(null, elementName, true); setSOAPEnvelope(node); } else if (lastNode.isComplete()) { - node = constructNode((OMElement) lastNode.getParent(), - elementName, - false); - ((OMNodeEx) lastNode).setNextOMSibling(node); - ((OMNodeEx) node).setPreviousOMSibling(lastNode); + OMContainer parent = lastNode.getParent(); + if (parent == document) { + // If we get here, this means that we found the SOAP envelope, but that it was + // preceded by a comment node. Since constructNode will create a new document + // based on the SOAP version of the envelope, we simply discard the last node + // and do as if we just encountered the first node in the document. + lastNode = null; + node = constructNode(null, elementName, true); + setSOAPEnvelope(node); + } else { + node = constructNode((OMElement)parent, + elementName, + false); + ((OMNodeEx) lastNode).setNextOMSibling(node); + ((OMNodeEx) node).setPreviousOMSibling(lastNode); + } } else { OMContainerEx e = (OMContainerEx) lastNode; node = constructNode((OMElement) lastNode, elementName, false);