cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sea...@apache.org
Subject svn commit: r694179 - in /cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
Date Thu, 11 Sep 2008 08:49:24 GMT
Author: seanoc
Date: Thu Sep 11 01:49:23 2008
New Revision: 694179

URL: http://svn.apache.org/viewvc?rev=694179&view=rev
Log:
Replaced NodeList

Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=694179&r1=694178&r2=694179&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Thu Sep 11 01:49:23 2008
@@ -38,7 +38,6 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.soap.Soap11;
@@ -51,6 +50,7 @@
 import org.apache.cxf.headers.Header;
 import org.apache.cxf.headers.HeaderManager;
 import org.apache.cxf.headers.HeaderProcessor;
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.phase.Phase;
@@ -129,47 +129,44 @@
         if (header == null) {
             return;
         }
-        NodeList headerEls = header.getChildNodes();
-        int len = headerEls.getLength();
-        for (int i = 0; i < len; i++) {
-            Node nd = headerEls.item(i);
-            if (Node.ELEMENT_NODE == nd.getNodeType()) {
-                Element hel = (Element)nd;
-                Bus b = message.getExchange().get(Bus.class);
-                HeaderProcessor p =  null;
-                if (b != null && b.getExtension(HeaderManager.class) != null) {
-                    p = b.getExtension(HeaderManager.class).getHeaderProcessor(hel.getNamespaceURI());
-                }
+        Element elem = DOMUtils.getFirstElement(header);
+        while (elem != null) {
+            Bus b = message.getExchange().get(Bus.class);
+            HeaderProcessor p =  null;
+            if (b != null && b.getExtension(HeaderManager.class) != null) {
+                p = b.getExtension(HeaderManager.class).getHeaderProcessor(elem.getNamespaceURI());
+            }
                 
-                Object obj;
-                DataBinding dataBinding = null;
-                if (p == null || p.getDataBinding() == null) {
-                    obj = nd;
-                } else {
-                    obj = p.getDataBinding().createReader(Node.class).read(nd);
-                }
-                //TODO - add the interceptors
+            Object obj;
+            DataBinding dataBinding = null;
+            if (p == null || p.getDataBinding() == null) {
+                obj = elem;
+            } else {
+                obj = p.getDataBinding().createReader(Node.class).read(elem);
+            }
+            //TODO - add the interceptors
                 
-                SoapHeader shead = new SoapHeader(new QName(nd.getNamespaceURI(),
-                        nd.getLocalName()),
-                                                   obj,
-                                                   dataBinding);
-                shead.setDirection(SoapHeader.Direction.DIRECTION_IN);
+            SoapHeader shead = new SoapHeader(new QName(elem.getNamespaceURI(),
+                                                        elem.getLocalName()),
+                                               obj,
+                                               dataBinding);
+            shead.setDirection(SoapHeader.Direction.DIRECTION_IN);
                 
-                String mu = hel.getAttributeNS(message.getVersion().getNamespace(),
-                        message.getVersion().getAttrNameMustUnderstand());
-                String act = hel.getAttributeNS(message.getVersion().getNamespace(),
-                        message.getVersion().getAttrNameRole());
+            String mu = elem.getAttributeNS(message.getVersion().getNamespace(),
+                    message.getVersion().getAttrNameMustUnderstand());
+            String act = elem.getAttributeNS(message.getVersion().getNamespace(),
+                    message.getVersion().getAttrNameRole());
                 
-                shead.setActor(act);
-                shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
-                Header oldHdr = message.getHeader(
-                        new QName(nd.getNamespaceURI(), nd.getLocalName()));
-                if (oldHdr != null) {
-                    message.getHeaders().remove(oldHdr);
-                } 
-                message.getHeaders().add(shead);                        
-            }
+            shead.setActor(act);
+            shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
+            Header oldHdr = message.getHeader(
+                    new QName(elem.getNamespaceURI(), elem.getLocalName()));
+            if (oldHdr != null) {
+                message.getHeaders().remove(oldHdr);
+            } 
+            message.getHeaders().add(shead);                        
+            
+            elem = DOMUtils.getNextElement(elem);
         }
     }
 

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java?rev=694179&r1=694178&r2=694179&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
Thu Sep 11 01:49:23 2008
@@ -58,6 +58,7 @@
 import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.binding.soap.SoapVersionFactory;
 import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.io.CachedOutputStream;
@@ -246,10 +247,9 @@
         control.verify();
 
         // Verify SOAPMessage header
-        SOAPMessage soapMessageNew = message.getContent(SOAPMessage.class);
-        NodeList headerEls = soapMessageNew.getSOAPHeader().getChildNodes();
+        SOAPMessage soapMessageNew = message.getContent(SOAPMessage.class);       
 
-        Element headerElementNew = (Element)headerEls.item(0);
+        Element headerElementNew = DOMUtils.getFirstElement(soapMessageNew.getSOAPHeader());
         
         SoapVersion soapVersion = Soap11.getInstance();
         assertEquals("false", headerElementNew.getAttributeNS(soapVersion.getNamespace(),
"mustUnderstand"));



Mime
View raw message