axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r544830 - /webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
Date Wed, 06 Jun 2007 13:01:27 GMT
Author: dims
Date: Wed Jun  6 06:01:26 2007
New Revision: 544830

URL: http://svn.apache.org/viewvc?view=rev&rev=544830
Log:
Fix for AXIS2-2773 - SAAJ - Prevent NPE from a few places because of namespaceURI, localname
being null

Modified:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java?view=diff&rev=544830&r1=544829&r2=544830
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
Wed Jun  6 06:01:26 2007
@@ -98,11 +98,19 @@
         String prefix = soapElement.getPrefix();
         String localName = soapElement.getLocalName();
         element.declareNamespace(namespaceURI, prefix);
-
-        SOAPBodyElementImpl childEle =
+        SOAPBodyElementImpl childEle;
+        
+        if (localName == null) {
+            childEle =
+                new SOAPBodyElementImpl(
+                        (ElementImpl)getOwnerDocument().createElementNS(namespaceURI,
+                                                                        ""));
+        } else {
+            childEle =
                 new SOAPBodyElementImpl(
                         (ElementImpl)getOwnerDocument().createElementNS(namespaceURI,
-                                                                        localName));
+                                                                        localName));    
       
+        }
         for (Iterator iter = soapElement.getAllAttributes(); iter.hasNext();) {
             Name name = (Name)iter.next();
             childEle.addAttribute(name, soapElement.getAttributeValue(name));
@@ -406,7 +414,16 @@
                                    domEle.getTagName().substring(0, indexOfColon));
         } else {
             localname = domEle.getLocalName();
-            ns = new NamespaceImpl(domEle.getNamespaceURI(), domEle.getPrefix());
+            if (domEle.getNamespaceURI() != null) {
+                ns = new NamespaceImpl(domEle.getNamespaceURI(), domEle.getPrefix());
+            } else {
+                if (domEle.getPrefix() != null) {
+                    ns = new NamespaceImpl("", domEle.getPrefix());
+                } else {
+                    ns = new NamespaceImpl("", "");
+                    
+                }
+            }
         }
         ElementImpl eleImpl =
                 new ElementImpl((DocumentImpl)this.getOwnerDocument(),
@@ -418,10 +435,18 @@
         NamedNodeMap domAttrs = domEle.getAttributes();
         for (int i = 0; i < domAttrs.getLength(); i++) {
             org.w3c.dom.Node attrNode = domAttrs.item(i);
-            saajEle.addAttribute(new PrefixedQName(attrNode.getNamespaceURI(),
-                                                   attrNode.getLocalName(),
-                                                   attrNode.getPrefix()),
-                                 attrNode.getNodeValue());
+            if (attrNode.getLocalName() == null) {
+                //local part is required.  "" is allowed to preserve compatibility with QName
1.0
+                saajEle.addAttribute(new PrefixedQName(attrNode.getNamespaceURI(),
+                                                       "",
+                                                       attrNode.getPrefix()),
+                                                       attrNode.getNodeValue());
+            } else {
+                saajEle.addAttribute(new PrefixedQName(attrNode.getNamespaceURI(),
+                                                       attrNode.getLocalName(),
+                                                       attrNode.getPrefix()),
+                                                       attrNode.getNodeValue());        
       
+            }
         }
 
         NodeList childNodes = node.getChildNodes();



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message