Axiom
  1. Axiom
  2. AXIOM-114

Soap envelope rpc-encoded namespace issue

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.8
    • Fix Version/s: 1.2.13
    • Component/s: None
    • Labels:
      None
    • Environment:
      java 1.6

      Description

      I have replaced saaj with axiom in my projects to manage soap handling.
      I have an rpc-encoded soap envelope containing the declarations of soapenv (xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/") and xsi (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance") namespaces.
      The first element of the soap body references soapenv in one of his attributes (soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"). Some xml elements in the soap body reference the xsi namespace (xsi:type="soapenc:string") as well.
      When I try to parse the soap body (extracted from the soap envelope) using JDOM or DOM4J I get a SaxParseException because the soapenv and xsi namespaces are not bound:
      org.xml.sax.SAXParseException: The prefix "soapenv" for attribute "soapenv:encodingStyle" associated with an element type "ns1:sendMessage" is not bound.
      Saaj handles correctly the soapenv and and xsi declarations moving them in the soap body; with axiom the soap body contain only the reference to those namespaces and not the declarations.
      The issue seems to be creating a StAXSource from Axiom payload element (obtained by calling axiomSoapMessage.getSOAPEnvelope().getBody().getFirstElement()); serializing payload calling serialize method namespace are correctly handled, but
      creating a StAXSource using XMLStreamReader and transforming it to a StreamResult I get an xml not parseable because namespaces are not bound.
      I have found a workaround transforming the StAXSource in a JDOMResult.
      The problem rises when you create a StAXSource from an Axiom payload element (calling axiomSoapMessage.getSOAPEnvelope().getBody().getFirstElement()). When you call the serialize method, namespaces are correctly handled; but if you create a StAXSource using an XMLStreamReader and try to transform it to a StreamResult you get the SaxParseException mentioned above.
      I have found a workaround transforming the StAXSource in a JDOMResult.

      1. AxiomSoapRpcEncoded.java
        2 kB
        Luca Cavanna
      2. AxiomSoapRpcEncodedOMSource.java
        2 kB
        Luca Cavanna
      3. soaprequest.xml
        1.0 kB
        Luca Cavanna

        Activity

        Hide
        Hudson added a comment -

        Integrated in Axis2 #1271 (See https://builds.apache.org/job/Axis2/1271/)
        Adapted to change in Axiom (related to AXIOM-114). (Revision 1292971)

        Result = ABORTED
        veithen :
        Files :

        • /axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl
        Show
        Hudson added a comment - Integrated in Axis2 #1271 (See https://builds.apache.org/job/Axis2/1271/ ) Adapted to change in Axiom (related to AXIOM-114 ). (Revision 1292971) Result = ABORTED veithen : Files : /axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl
        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #796 (See https://builds.apache.org/job/ws-axiom-trunk/796/)
        Refactored the API introduced by AXIOM-114. Adding getXMLStreamReader methods with various arguments is not going to scale well. Instead, introduced an OMXMLStreamReaderConfiguration class that can be used to specify advanced options. That class can be extended more easily.

        Note that AXIOM-114 has not been included in any release yet, so that we don't need to preserve the old API. (Revision 1292920)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #796 (See https://builds.apache.org/job/ws-axiom-trunk/796/ ) Refactored the API introduced by AXIOM-114 . Adding getXMLStreamReader methods with various arguments is not going to scale well. Instead, introduced an OMXMLStreamReaderConfiguration class that can be used to specify advanced options. That class can be extended more easily. Note that AXIOM-114 has not been included in any release yet, so that we don't need to preserve the old API. (Revision 1292920) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
        Hide
        Hudson added a comment -

        Integrated in Axis2 #1080 (See https://builds.apache.org/job/Axis2/1080/)
        Use the feature introduced by AXIOM-114 to take into account the namespace declarations on the SOAP envelope and body.

        veithen :
        Files :

        • /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl
        • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
        • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
        • /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl
        • /axis/axis2/java/core/trunk/modules/jaxbri/src/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
        • /axis/axis2/java/core/trunk/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
        • /axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl
        Show
        Hudson added a comment - Integrated in Axis2 #1080 (See https://builds.apache.org/job/Axis2/1080/ ) Use the feature introduced by AXIOM-114 to take into account the namespace declarations on the SOAP envelope and body. veithen : Files : /axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl /axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl /axis/axis2/java/core/trunk/modules/jaxbri/src/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl /axis/axis2/java/core/trunk/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl /axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl
        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #630 (See https://builds.apache.org/job/ws-axiom-trunk/630/)
        AXIOM-114: Added a method to OMElement that allows to get an XMLStreamReader that strictly preserves the namespace context (by generating additional namespace declarations on the root START_ELEMENT event).

        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMStAXWrapper.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/AXIOM-114.xml
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #630 (See https://builds.apache.org/job/ws-axiom-trunk/630/ ) AXIOM-114 : Added a method to OMElement that allows to get an XMLStreamReader that strictly preserves the namespace context (by generating additional namespace declarations on the root START_ELEMENT event). veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java /webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMStAXWrapper.java /webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/ AXIOM-114 .xml
        Hide
        Luca Cavanna added a comment -

        Great, you're right! Thank you very much.
        I've tested it using the current version of axiom downloaded from subversion trunk.

        Show
        Luca Cavanna added a comment - Great, you're right! Thank you very much. I've tested it using the current version of axiom downloaded from subversion trunk.
        Hide
        Andreas Veithen added a comment -

        A fixed the issue in OMXMLReader some time ago, but the fix didn't make it into the 1.2.8 release. Can you test with a snapshot version?

        Show
        Andreas Veithen added a comment - A fixed the issue in OMXMLReader some time ago, but the fix didn't make it into the 1.2.8 release. Can you test with a snapshot version?
        Hide
        Luca Cavanna added a comment -

        When you replace StAXSource with OMSource the issue remains the same.
        OMXMLReader used by OMSource doesn't correctly handles namespaces declaration and the result of the transformation from OMSource to StreamResult can't be parsed correctly as an XML.

        Thank you very much for your quick answer.

        Show
        Luca Cavanna added a comment - When you replace StAXSource with OMSource the issue remains the same. OMXMLReader used by OMSource doesn't correctly handles namespaces declaration and the result of the transformation from OMSource to StreamResult can't be parsed correctly as an XML. Thank you very much for your quick answer.
        Hide
        Andreas Veithen added a comment -

        There is indeed an issue with the StAX stream produced by OMElement#getXMLStreamReader() with respect to namespaces declared on ancestors of the element. The problem is that the code which implements the XMLStreamReader is fairly complex (more than 1500 lines of code). I'm planning to refactor that code to split it into more manageable pieces, so that the kind of issues described here can be solved more easily. I'm also trying to stabilize the existing code by increasing the test case coverage. Since all this will still require some significant amount of work, the issue will not be solved in the near future.

        On the other hand, the error indicates that there is an intermediary conversion from StAX to SAX. In that case it is maybe better anyway to use OMSource [1] since it converts directly to SAX.

        [1] http://ws.apache.org/commons/axiom/apidocs/org/apache/axiom/om/impl/jaxp/OMSource.html

        Show
        Andreas Veithen added a comment - There is indeed an issue with the StAX stream produced by OMElement#getXMLStreamReader() with respect to namespaces declared on ancestors of the element. The problem is that the code which implements the XMLStreamReader is fairly complex (more than 1500 lines of code). I'm planning to refactor that code to split it into more manageable pieces, so that the kind of issues described here can be solved more easily. I'm also trying to stabilize the existing code by increasing the test case coverage. Since all this will still require some significant amount of work, the issue will not be solved in the near future. On the other hand, the error indicates that there is an intermediary conversion from StAX to SAX. In that case it is maybe better anyway to use OMSource [1] since it converts directly to SAX. [1] http://ws.apache.org/commons/axiom/apidocs/org/apache/axiom/om/impl/jaxp/OMSource.html

          People

          • Assignee:
            Andreas Veithen
            Reporter:
            Luca Cavanna
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development