You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/08/11 11:45:27 UTC

svn commit: r1371897 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/ axiom-api/src/test/resources/soap/soap11/ axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/ axiom-testsuite/sr...

Author: veithen
Date: Sat Aug 11 09:45:27 2012
New Revision: 1371897

URL: http://svn.apache.org/viewvc?rev=1371897&view=rev
Log:
Fixed the code that is expected to handle the case where additional elements appear after the SOAP body (which is allowed by SOAP 1.1, but not SOAP 1.2).

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/additional-element-after-body.xml   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/additional-element-after-body.xml   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/impl/builder/StAXSOAPModelBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java

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=1371897&r1=1371896&r2=1371897&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 Aug 11 09:45:27 2012
@@ -266,52 +266,50 @@ public class StAXSOAPModelBuilder extend
             processAttributes(element);
 
         } else if (elementLevel == 2) {
-            // Must be in the right namespace regardless
             String elementNS = parser.getNamespaceURI();
 
-            if (!(soapFactory.getSoapVersionURI().equals(elementNS))) {
-                if (!bodyPresent ||
-                        soapFactory.getSOAPVersion() != SOAP11Version.getSingleton()) {
-                    throw new SOAPProcessingException("Disallowed element found inside Envelope : {"
-                            + elementNS + "}" + elementName);
-                }
-            }
-
-            // this is either a header or a body
-            if (elementName.equals(SOAPConstants.HEADER_LOCAL_NAME)) {
-                if (headerPresent) {
-                    throw new SOAPProcessingException("Multiple headers encountered!",
-                                                      getSenderFaultCode());
-                }
-                if (bodyPresent) {
-                    throw new SOAPProcessingException("Header Body wrong order!",
-                                                      getSenderFaultCode());
-                }
-                headerPresent = true;
-                element =
-                        soapFactory.createSOAPHeader((SOAPEnvelope) parent,
-                                                     this);
-
-                processNamespaceData(element, true);
-                processAttributes(element);
-
-            } else if (elementName.equals(SOAPConstants.BODY_LOCAL_NAME)) {
-                if (bodyPresent) {
-                    throw new SOAPProcessingException("Multiple body elements encountered",
+            if (soapFactory.getSoapVersionURI().equals(elementNS)) {
+                // this is either a header or a body
+                if (elementName.equals(SOAPConstants.HEADER_LOCAL_NAME)) {
+                    if (headerPresent) {
+                        throw new SOAPProcessingException("Multiple headers encountered!",
+                                                          getSenderFaultCode());
+                    }
+                    if (bodyPresent) {
+                        throw new SOAPProcessingException("Header Body wrong order!",
+                                                          getSenderFaultCode());
+                    }
+                    headerPresent = true;
+                    element =
+                            soapFactory.createSOAPHeader((SOAPEnvelope) parent,
+                                                         this);
+    
+                    processNamespaceData(element, true);
+                    processAttributes(element);
+    
+                } else if (elementName.equals(SOAPConstants.BODY_LOCAL_NAME)) {
+                    if (bodyPresent) {
+                        throw new SOAPProcessingException("Multiple body elements encountered",
+                                                          getSenderFaultCode());
+                    }
+                    bodyPresent = true;
+                    element =
+                            soapFactory.createSOAPBody((SOAPEnvelope) parent,
+                                                       this);
+    
+                    processNamespaceData(element, true);
+                    processAttributes(element);
+                } else {
+                    throw new SOAPProcessingException(elementName + " is not supported here.",
                                                       getSenderFaultCode());
                 }
-                bodyPresent = true;
-                element =
-                        soapFactory.createSOAPBody((SOAPEnvelope) parent,
-                                                   this);
-
-                processNamespaceData(element, true);
+            } else if (soapFactory.getSOAPVersion() == SOAP11Version.getSingleton() && bodyPresent) {
+                element = omfactory.createOMElement(parser.getLocalName(), parent, this);
+                processNamespaceData(element, false);
                 processAttributes(element);
             } else {
-                throw new SOAPProcessingException(elementName
-                        +
-                        " is not supported here. Envelope can not have elements other than Header and Body.",
-                                                  getSenderFaultCode());
+                throw new SOAPProcessingException("Disallowed element found inside Envelope : {"
+                        + elementNS + "}" + elementName);
             }
         } else if ((elementLevel == 3)
                 &&

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/additional-element-after-body.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/additional-element-after-body.xml?rev=1371897&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/additional-element-after-body.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/additional-element-after-body.xml Sat Aug 11 09:45:27 2012
@@ -0,0 +1,31 @@
+<?xml version='1.0' ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<!-- 
+  According do SOAP 1.1, an envelope "MAY contain additional sub elements. If present these elements MUST be
+  namespace-qualified and MUST follow the SOAP Body element."
+ -->
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
+    <env:Body>
+        <ns:testRequest xmlns:ns="urn:test"/>
+    </env:Body>
+    <ns:additionalElement xmlns:ns="urn:test">
+        <!-- Some content -->
+    </ns:additionalElement>
+</env:Envelope>
\ No newline at end of file

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/additional-element-after-body.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1371897&r1=1371896&r2=1371897&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Sat Aug 11 09:45:27 2012
@@ -32,12 +32,13 @@ public class SOAPTestSuiteBuilder extend
     private static final String[] badSOAPFiles = { "wrongSoapNs.xml", "notnamespaceQualified.xml", "soap11/twoheaders.xml", "soap11/twoBodymessage.xml",
             "soap11/envelopeMissing.xml", "soap11/haederBodyWrongOrder.xml", "soap11/invalid-faultcode.xml", "soap11/invalid-faultstring.xml",
             "soap11/invalid-faultactor.xml", "soap11/processing-instruction.xml", "soap11/entity-reference.xml",
-            "soap12/header-bad-case.xml", "soap12/header-no-namespace.xml", "soap12/processing-instruction.xml", "soap12/entity-reference.xml" };
+            "soap12/header-bad-case.xml", "soap12/header-no-namespace.xml", "soap12/processing-instruction.xml", "soap12/entity-reference.xml",
+            "soap12/additional-element-after-body.xml"};
     
     private static final String[] goodSOAPFiles = { TestConstants.WHITESPACE_MESSAGE,
         TestConstants.MINIMAL_MESSAGE, TestConstants.REALLY_BIG_MESSAGE,
         TestConstants.EMPTY_BODY_MESSAGE, "soap/soap11/soapfault.xml", "soap/soap11/bodyNotQualified.xml",
-        "soap/soap11/faultstring-with-comment.xml"};
+        "soap/soap11/faultstring-with-comment.xml", "soap/soap11/additional-element-after-body.xml"};
     
     private static final QName[] generalQNames = {
         new QName("root"),

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/additional-element-after-body.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/additional-element-after-body.xml?rev=1371897&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/additional-element-after-body.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/additional-element-after-body.xml Sat Aug 11 09:45:27 2012
@@ -0,0 +1,30 @@
+<?xml version='1.0' ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<!-- 
+  Additional elements after the body are allowed in SOAP 1.1, but not SOAP 1.2.
+ -->
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
+    <env:Body>
+        <ns:testRequest xmlns:ns="urn:test"/>
+    </env:Body>
+    <ns:additionalElement xmlns:ns="urn:test">
+        <!-- Some content -->
+    </ns:additionalElement>
+</env:Envelope>
\ No newline at end of file

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/badsoap/soap12/additional-element-after-body.xml
------------------------------------------------------------------------------
    svn:eol-style = native