cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1304535 - in /cxf/trunk/rt/bindings/soap/src: main/java/org/apache/cxf/binding/soap/interceptor/ test/java/org/apache/cxf/binding/soap/interceptor/
Date Fri, 23 Mar 2012 18:10:40 GMT
Author: dkulp
Date: Fri Mar 23 18:10:40 2012
New Revision: 1304535

URL: http://svn.apache.org/viewvc?rev=1304535&view=rev
Log:
[CXF-4181] Fix fault qname namespace handling

Added:
    cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml
  (with props)
Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
    cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java?rev=1304535&r1=1304534&r2=1304535&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
Fri Mar 23 18:10:40 2012
@@ -27,7 +27,6 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.xpath.XPathConstants;
 
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
@@ -71,9 +70,23 @@ public class Soap12FaultInInterceptor ex
         Map<String, String> ns = new HashMap<String, String>();
         ns.put("s", Soap12.SOAP_NAMESPACE);
         XPathUtils xu = new XPathUtils(ns);        
-        
         try {
-            Document fault = StaxUtils.read(new FragmentStreamReader(reader));
+            Node mainNode = message.getContent(Node.class);
+            
+            Node fault = null;
+            if (mainNode != null) {
+                Node bodyNode = (Node) xu.getValue("//s:Body",
+                                                   mainNode,
+                                                   XPathConstants.NODE);
+
+                StaxUtils.readDocElements(bodyNode.getOwnerDocument(),
+                                          bodyNode,
+                                          new FragmentStreamReader(reader),
+                                          false, false);
+                fault = (Element)xu.getValue("//s:Fault", bodyNode, XPathConstants.NODE);
+            } else {
+                fault = StaxUtils.read(new FragmentStreamReader(reader));
+            }
             Element el = (Element)xu.getValue("//s:Fault/s:Code/s:Value", 
                                       fault, 
                                       XPathConstants.NODE);

Modified: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java?rev=1304535&r1=1304534&r2=1304535&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
Fri Mar 23 18:10:40 2012
@@ -178,4 +178,27 @@ public class SoapFaultSerializerTest ext
         assertEquals(Soap12.getInstance().getReceiver(), fault2.getFaultCode());
     }
 
+    @Test
+    public void testCXF4181() throws Exception {
+
+        SoapMessage m = new SoapMessage(new MessageImpl());
+        m.setVersion(Soap12.getInstance());        
+
+
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(this.getClass()
+                                                                 .getResourceAsStream("cxf4181.xml"));
+
+        m.setContent(XMLStreamReader.class, reader);
+
+        new ReadHeadersInterceptor(null).handleMessage(m);
+        Soap12FaultInInterceptor inInterceptor = new Soap12FaultInInterceptor();
+        inInterceptor.handleMessage(m);
+
+        SoapFault fault2 = (SoapFault)m.getContent(Exception.class);
+        assertNotNull(fault2);
+        
+        assertEquals(Soap12.getInstance().getSender(), fault2.getFaultCode());
+        assertEquals(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "FailedAuthentication"),

+                     fault2.getSubCode());
+    }
 }

Added: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml?rev=1304535&view=auto
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml
(added)
+++ cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml
Fri Mar 23 18:10:40 2012
@@ -0,0 +1,18 @@
+<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" 
+            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"

+            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"

+            xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust">
+  <S:Body>
+    <S:Fault>
+      <S:Code>
+        <S:Value>S:Sender</S:Value>
+        <S:Subcode>
+          <S:Value>wst:FailedAuthentication</S:Value>
+        </S:Subcode>
+      </S:Code>
+      <S:Reason>
+        <S:Text xml:lang="en-US">Authentication Failure</S:Text>
+      </S:Reason>
+    </S:Fault>
+  </S:Body>
+</S:Envelope>

Propchange: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/cxf4181.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message