Author: gdaniels
Date: Tue Mar  6 22:57:21 2007
New Revision: 515477

URL: http://svn.apache.org/viewvc?view=rev&rev=515477
Log:
A few small changes.

* Store away the namespace when building the SOAP envelope in 
StAXSOAPModelBuilder - this will help to clean up identifySOAPVersion() among 
other things.

* Stop doing case-insensitive comparisons when parsing SOAP - XML is case 
sensitive.

* Clean up SOAPEnvelopeImpl.getHeader() a little, since <soapenv:Header> will 
always be the first element inside the envelope if it's present.

I ran the Axiom tests and the Axis2 build successfully, but am not 100% 
confident that the new axiom jars made it over to my m2 repository... if there 
are any problems I'll be up in about 6-7 hours.

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-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.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?view=diff&rev=515477&r1=515476&r2=515477
==============================================================================
--- 
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
 Tue Mar  6 22:57:21 2007
@@ -50,6 +50,7 @@
      */
     private SOAPEnvelope envelope;
     private OMNamespace envelopeNamespace;
+    private String namespaceURI;
 
 
     private SOAPFactory soapFactory;
@@ -230,14 +231,14 @@
 
             // Now I've found a SOAP Envelope, now create SOAPDocument and 
SOAPEnvelope here.
 
-            if 
(!elementName.equalsIgnoreCase(SOAPConstants.SOAPENVELOPE_LOCAL_NAME)) {
+            if (!elementName.equals(SOAPConstants.SOAPENVELOPE_LOCAL_NAME)) {
                 throw new SOAPProcessingException("First Element must contain 
the local name, "
-                        + SOAPConstants.SOAPENVELOPE_LOCAL_NAME, 
SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
+                        + SOAPConstants.SOAPENVELOPE_LOCAL_NAME, 
SOAPConstants.FAULT_CODE_SENDER);
             }
 
             // determine SOAP version and from that determine a proper factory 
here.
             if (soapFactory == null) {
-                String namespaceURI = this.parser.getNamespaceURI();
+                namespaceURI = this.parser.getNamespaceURI();
                 if 
(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
                     soapFactory = OMAbstractFactory.getSOAP12Factory();
                     if(isDebugEnabled) {
@@ -252,6 +253,8 @@
                     throw new SOAPProcessingException("Only SOAP 1.1 or SOAP 
1.2 messages are supported in the" +
                             " system", 
SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
                 }
+            } else {
+                namespaceURI = soapFactory.getSoapVersionURI();
             }
 
             // create a SOAPMessage to hold the SOAP envelope and assign the 
SOAP envelope in that.
@@ -268,6 +271,15 @@
             processAttributes(element);
 
         } else if (elementLevel == 2) {
+            // Must be in the right namespace regardless
+            String elementNS = parser.getNamespaceURI();
+
+            if (!(namespaceURI.equals(elementNS))) {
+                if (!bodyPresent || 
!SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
+                    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)) {
@@ -304,7 +316,7 @@
             }
         } else if ((elementLevel == 3)
                 &&
-                
parent.getLocalName().equalsIgnoreCase(SOAPConstants.HEADER_LOCAL_NAME)) {
+                parent.getLocalName().equals(SOAPConstants.HEADER_LOCAL_NAME)) 
{
 
             // this is a headerblock
             try {
@@ -318,8 +330,8 @@
             processAttributes(element);
 
         } else if ((elementLevel == 3) &&
-                
parent.getLocalName().equalsIgnoreCase(SOAPConstants.BODY_LOCAL_NAME) &&
-                
elementName.equalsIgnoreCase(SOAPConstants.BODY_FAULT_LOCAL_NAME)) {
+                parent.getLocalName().equals(SOAPConstants.BODY_LOCAL_NAME) &&
+                elementName.equals(SOAPConstants.BODY_FAULT_LOCAL_NAME)) {
 
             // this is a headerblock
             element = soapFactory.createSOAPFault((SOAPBody) parent, this);

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java?view=diff&rev=515477&r1=515476&r2=515477
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
 Tue Mar  6 22:57:21 2007
@@ -77,15 +77,21 @@
      * @throws OMException
      */
     public SOAPHeader getHeader() throws OMException {
-        SOAPHeader header =
-                (SOAPHeader) getFirstChildWithName(
-                        HEADER_QNAME);
-        if (builder == null && header == null) {
-            inferFactory();
-            header = ((SOAPFactory) factory).createSOAPHeader(this);
-            addChild(header);
+        // Header must be the first child
+        OMElement header = getFirstElement();
+        if (header == null) {
+            if (builder == null) {
+                inferFactory();
+                header = ((SOAPFactory) factory).createSOAPHeader(this);
+                addChild(header);
+            } else {
+                return null;
+            }
+        } else if (!(header instanceof SOAPHeader)) {
+            return null;
         }
-        return header;
+
+        return (SOAPHeader)header;
     }
 
     private void inferFactory() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to