cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1440686 - in /cxf/branches/2.7.x-fixes: ./ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/
Date Wed, 30 Jan 2013 21:36:01 GMT
Author: ay
Date: Wed Jan 30 21:36:01 2013
New Revision: 1440686

URL: http://svn.apache.org/viewvc?rev=1440686&view=rev
Log:
Merged revisions 1440485 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1440485 | ay | 2013-01-30 16:48:24 +0100 (Wed, 30 Jan 2013) | 1 line
  
  [CXF-4794] Soap 1.1 service returns an invalid soap fault for soap 1.2 requests
........

Added:
    cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml
      - copied unchanged from r1440485, cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml
Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
    cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
    cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
Wed Jan 30 21:36:01 2013
@@ -28,6 +28,7 @@ NO_OPERATION=No such operation: {0}
 ATTACHMENT_IO=Attachment IO Exception: {0}
 INVALID_VERSION="{0}", the namespace on the "{1}" element, is not a valid SOAP version.
 INVALID_11_VERSION=A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.
+INVALID_FAULT=Invalid SOAP fault content
 NO_NAMESPACE=No namespace on "{0}" element. You must send a SOAP request.
 BP_2211_RPCLIT_CANNOT_BE_NULL=Cannot write part {0}. RPC/Literal parts cannot be null. (WS-I
BP R2211)
 UNKNOWN_RPC_LIT_PART=Found element {0} but could not find matching RPC/Literal part

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Wed Jan 30 21:36:01 2013
@@ -144,10 +144,9 @@ public class ReadHeadersInterceptor exte
                 SoapVersion soapVersion = readVersion(xmlReader, message);
                 if (soapVersion == Soap12.getInstance()
                     && version == Soap11.getInstance()) {
-                    throw new SoapFault(new Message("INVALID_11_VERSION", LOG, 
-                                                    Soap12.getInstance().getNamespace(),
-                                                    xmlReader.getLocalName()),
-                                        Soap11.getInstance().getVersionMismatch());     
              
+                    message.setVersion(version);
+                    throw new SoapFault(new Message("INVALID_11_VERSION", LOG),
+                                        version.getVersionMismatch());                  
 
                 }
 
                 XMLStreamReader filteredReader = new PartialXMLStreamReader(xmlReader, message.getVersion()

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
Wed Jan 30 21:36:01 2013
@@ -19,21 +19,26 @@
 
 package org.apache.cxf.binding.soap.interceptor;
 
+import java.util.logging.Logger;
+
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
 import org.w3c.dom.Element;
 
+import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.ClientFaultConverter;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.StaxUtils;
 
 public class Soap11FaultInInterceptor extends AbstractSoapInterceptor {
-
+    private static final Logger LOG = LogUtils.getL7dLogger(Soap11FaultInInterceptor.class);
     
     public Soap11FaultInInterceptor() {
         super(Phase.UNMARSHAL);
@@ -71,7 +76,11 @@ public class Soap11FaultInInterceptor ex
                                 e,
                                 message.getVersion().getSender());
         }
-
+        // if the fault's content is invalid and fautlCode is not found, blame the receiver
+        if (faultCode == null) {
+            faultCode = Soap11.getInstance().getReceiver();
+            exMessage = new Message("INVALID_FAULT", LOG).toString();
+        }
         SoapFault fault = new SoapFault(exMessage, faultCode);
         fault.setDetail(detail);
         fault.setRole(role);

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
Wed Jan 30 21:36:01 2013
@@ -28,8 +28,10 @@ import javax.xml.stream.XMLStreamWriter;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
+import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.Soap12FaultOutInterceptor.Soap12FaultOutInterceptorInternal;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.phase.Phase;
@@ -44,7 +46,11 @@ public class Soap11FaultOutInterceptor e
     public void handleMessage(SoapMessage message) throws Fault {
         Fault f = (Fault) message.getContent(Exception.class);
         message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode());
-        message.getInterceptorChain().add(Soap11FaultOutInterceptorInternal.INSTANCE);
+        if (message.getVersion() == Soap11.getInstance()) {
+            message.getInterceptorChain().add(Soap11FaultOutInterceptorInternal.INSTANCE);
+        } else {
+            message.getInterceptorChain().add(Soap12FaultOutInterceptorInternal.INSTANCE);
           
+        }
     }
     
     static class Soap11FaultOutInterceptorInternal extends AbstractSoapInterceptor {

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
Wed Jan 30 21:36:01 2013
@@ -21,6 +21,7 @@ package org.apache.cxf.binding.soap.inte
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -34,6 +35,8 @@ import org.apache.cxf.binding.soap.Soap1
 import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.interceptor.ClientFaultConverter;
@@ -44,6 +47,7 @@ import org.apache.cxf.staxutils.StaxUtil
 import org.apache.cxf.staxutils.W3CDOMStreamReader;
 
 public class Soap12FaultInInterceptor extends AbstractSoapInterceptor {
+    private static final Logger LOG = LogUtils.getL7dLogger(Soap12FaultInInterceptor.class);
     
     public Soap12FaultInInterceptor() {
         super(Phase.UNMARSHAL);
@@ -129,7 +133,12 @@ public class Soap12FaultInInterceptor ex
                                 e,
                                 message.getVersion().getSender());
         }
-
+        // if the fault's content is invalid and fautlCode is not found, blame the receiver
+        if (faultCode == null) {
+            faultCode = Soap12.getInstance().getReceiver();
+            exMessage = new Message("INVALID_FAULT", LOG).toString();
+        }
+        
         SoapFault fault = new SoapFault(exMessage, faultCode);
         fault.setSubCode(subCode);
         fault.setDetail(detail);

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
Wed Jan 30 21:36:01 2013
@@ -28,6 +28,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
+import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor.Soap11FaultOutInterceptorInternal;
@@ -46,7 +47,7 @@ public class Soap12FaultOutInterceptor e
     public void handleMessage(SoapMessage message) throws Fault {
         Fault f = (Fault) message.getContent(Exception.class);
         message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode());
-        if (message.getVersion().getVersion() == 1.1) {
+        if (message.getVersion() == Soap11.getInstance()) {
             message.getInterceptorChain().add(Soap11FaultOutInterceptorInternal.INSTANCE);
         } else {
             message.getInterceptorChain().add(Soap12FaultOutInterceptorInternal.INSTANCE);

Modified: cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
Wed Jan 30 21:36:01 2013
@@ -37,6 +37,10 @@ public class Server extends AbstractBusT
         ep = Endpoint.publish(address, implementor);
         EndpointImpl epi = (EndpointImpl)ep;
         epi.getService().getInInterceptors().add(new URIMappingInterceptor());
+        
+        implementor = new org.apache.hello_world_soap_http.GreeterImpl();
+        address = "http://localhost:" + PORT + "/SoapContext/Soap11Port";
+        ep = Endpoint.publish(address, implementor);
     }
 
     public void tearDown() throws Exception {

Modified: cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java?rev=1440686&r1=1440685&r2=1440686&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
Wed Jan 30 21:36:01 2013
@@ -22,6 +22,7 @@
 package org.apache.cxf.systest.soap12;
 
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -34,7 +35,9 @@ import javax.xml.xpath.XPathConstants;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
+import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.Soap12;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
@@ -178,6 +181,44 @@ public class Soap12ClientServerTest exte
         assertTrue(reason.contains("No such operation: greetMe"));        
     }
     
+    @Test
+    public void testSayHiSoap12ToSoap11() throws Exception {
+        HttpURLConnection httpConnection = 
+            getHttpConnection("http://localhost:" + PORT + "/SoapContext/Soap11Port/sayHi");
+        httpConnection.setDoOutput(true);
+        
+        InputStream reqin = Soap12ClientServerTest.class.getResourceAsStream("sayHiSOAP12Req.xml");
+        assertNotNull("could not load test data", reqin);
+
+        httpConnection.setRequestMethod("POST");
+        httpConnection.addRequestProperty("Content-Type", "text/xml");
+        OutputStream reqout = httpConnection.getOutputStream();
+        IOUtils.copy(reqin, reqout);
+        reqout.close();
+
+        assertEquals(500, httpConnection.getResponseCode());
+        
+        InputStream respin = httpConnection.getErrorStream();
+        assertNotNull(respin);
+        
+        // we expect a soap 1.1 fault from the soap 1.1 test service that does not support
soap 1.2
+        assertEquals("text/xml;charset=utf-8", httpConnection.getContentType().toLowerCase());
+       
+        Document doc = XMLUtils.parse(respin);
+        assertNotNull(doc);
+
+        Map<String, String> ns = new HashMap<String, String>();
+        ns.put("soap11", Soap11.SOAP_NAMESPACE);
+        XPathUtils xu = new XPathUtils(ns);
+        Node fault = (Node) xu.getValue("/soap11:Envelope/soap11:Body/soap11:Fault", doc,
XPathConstants.NODE);
+        assertNotNull(fault);
+        String codev = (String) xu.getValue("//faultcode/text()", 
+                                            fault, 
+                                            XPathConstants.STRING);
+        
+        assertNotNull(codev);
+        assertTrue("VersionMismatch expected", codev.endsWith("VersionMismatch"));
+    }
 
     private Greeter getGreeter() throws NumberFormatException, MalformedURLException {
         URL wsdl = getClass().getResource("/wsdl/hello_world_soap12.wsdl");



Mime
View raw message