cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1307446 - in /cxf/branches/2.5.x-fixes: common/common/src/main/java/org/apache/cxf/staxutils/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/
Date Fri, 30 Mar 2012 14:36:54 GMT
Author: dkulp
Date: Fri Mar 30 14:36:54 2012
New Revision: 1307446

URL: http://svn.apache.org/viewvc?rev=1307446&view=rev
Log:
Merged revisions 1307438 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1307438 | dkulp | 2012-03-30 10:21:08 -0400 (Fri, 30 Mar 2012) | 3 lines

  [CXF-4181] Another fix for SAAJ and fault handling that should allow the
  SAAJInInterceptor to retain all the information about the faults

........

Modified:
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=1307446&r1=1307445&r2=1307446&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
Fri Mar 30 14:36:54 2012
@@ -68,6 +68,11 @@ public class W3CDOMStreamWriter implemen
         currentNode = e;
         ((W3CNamespaceContext)context).setElement(e);
     }
+    public W3CDOMStreamWriter(Document owner, Element e) {
+        this.document = owner;
+        currentNode = e;
+        ((W3CNamespaceContext)context).setElement(e);
+    }
     
     public Element getCurrentNode() {
         if (currentNode instanceof Element) {

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=1307446&r1=1307445&r2=1307446&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Fri Mar 30 14:36:54 2012
@@ -29,10 +29,8 @@ import java.util.ResourceBundle;
 
 import javax.xml.namespace.QName;
 import javax.xml.soap.AttachmentPart;
-import javax.xml.soap.Detail;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFault;
 import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.SOAPPart;
@@ -54,8 +52,6 @@ import org.apache.cxf.binding.soap.SoapH
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
-import org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor;
-import org.apache.cxf.binding.soap.interceptor.Soap12FaultInInterceptor;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.databinding.DataBinding;
@@ -224,67 +220,12 @@ public class SAAJInInterceptor extends A
                 soapMessage.getSOAPPart().getEnvelope().addHeader();
             }
             
-
-            if (hasFault(message, xmlReader)) {
-                SoapFault fault = 
-                    message.getVersion() instanceof Soap11 
-                    ? Soap11FaultInInterceptor.unmarshalFault(message, xmlReader)
-                    : Soap12FaultInInterceptor.unmarshalFault(message, xmlReader);
-<<<<<<< HEAD
-                if (fault.getFaultCode() != null) {
-                    soapFault.setFaultCode(fault.getFaultCode());
-                }
-                if (fault.getMessage() != null) {
-                    soapFault.setFaultString(fault.getMessage());
-                }
-                if (fault.getRole() != null) {
-                    soapFault.setFaultActor(fault.getRole());
-                }
-                if (fault.getDetail() != null
-                    && fault.getDetail().getFirstChild() != null) {
-=======
->>>>>>> 941b6cf... [CXF-4181] Fix for SAAJ + SOAP 1.2 fault...
-                    
-                SOAPFault soapFault = 
-                    soapMessage.getSOAPPart().getEnvelope().getBody().getFault();
-                if (soapFault == null) {
-                    soapFault = 
-                        soapMessage.getSOAPPart().getEnvelope().getBody().addFault();
-                    if (fault.getFaultCode() != null) {
-                        SAAJUtils.setFaultCode(soapFault, fault.getFaultCode());
-                    }
-                    if (fault.getMessage() != null) {
-                        soapFault.setFaultString(fault.getMessage());
-                    }
-                    if (fault.getRole() != null) {
-                        soapFault.setFaultActor(fault.getRole());
-                    }
-                    if (fault.getDetail() != null
-                        && fault.getDetail().getFirstChild() != null) {
-                        
-                        Detail detail = null;
-                        Node child = fault.getDetail().getFirstChild();
-                        if (child != null) {
-                            detail = soapFault.addDetail();
-                        }
-                        while (child != null) {
-                            if (Node.ELEMENT_NODE == child.getNodeType()) {
-                                Node importedChild = soapMessage.getSOAPPart().importNode(child,
true);
-                                detail.appendChild(importedChild);
-                            }
-                            child = child.getNextSibling();
-                        }
-                    }
-                }
-                DOMSource bodySource = new DOMSource(soapFault);
-                xmlReader = StaxUtils.createXMLStreamReader(bodySource);
-            } else { 
-                StaxUtils.readDocElements(soapMessage.getSOAPBody(), xmlReader, true, true);
-                DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
-                xmlReader = StaxUtils.createXMLStreamReader(bodySource);
-                xmlReader.nextTag();
-                xmlReader.nextTag(); // move past body tag
-            }
+            StaxUtils.readDocElements(soapMessage.getSOAPPart().getEnvelope().getBody(),
+                                      xmlReader, true, true);
+            DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
+            xmlReader = StaxUtils.createXMLStreamReader(bodySource);
+            xmlReader.nextTag();
+            xmlReader.nextTag(); // move past body tag
             message.setContent(XMLStreamReader.class, xmlReader);           
         } catch (SOAPException soape) {
             throw new SoapFault(new org.apache.cxf.common.i18n.Message(
@@ -342,15 +283,4 @@ public class SAAJInInterceptor extends A
             elem = DOMUtils.getNextElement(elem);
         }
     }
-
-
-    private static boolean hasFault(SoapMessage message, 
-                                    XMLStreamReader xmlReader) {
-        try {
-            QName name = xmlReader.getName();
-            return message.getVersion().getFault().equals(name);
-        } catch (Exception e) {
-            return false;
-        }
-    }
 }

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java?rev=1307446&r1=1307445&r2=1307446&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
Fri Mar 30 14:36:54 2012
@@ -33,7 +33,7 @@ import javax.xml.soap.SOAPMessage;
 import javax.xml.stream.XMLStreamReader;
 
 import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.soap.Soap12;
@@ -126,8 +126,15 @@ public class SAAJInInterceptorTest exten
         assertEquals("soap:Server", fault.getFaultCode());
         assertEquals("This is a fault string", fault.getFaultString());
         Detail faultDetail = fault.getDetail();
-        NodeList faultDetailChildNodes = faultDetail.getChildNodes();
-        assertEquals(2, faultDetailChildNodes.getLength());
+        int count = 0;
+        Node nd = faultDetail.getFirstChild();
+        while (nd != null) {
+            if (nd instanceof Element) {
+                count++;
+            }
+            nd = nd.getNextSibling();
+        }
+        assertEquals(2, count);
         
         Iterator<?> detailEntries = faultDetail.getDetailEntries();
         DetailEntry detailEntry = (DetailEntry)detailEntries.next();



Mime
View raw message