cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1440485 - in /cxf/trunk: 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 15:48:25 GMT
Author: ay
Date: Wed Jan 30 15:48:24 2013
New Revision: 1440485

URL: http://svn.apache.org/viewvc?rev=1440485&view=rev
Log:
[CXF-4794] Soap 1.1 service returns an invalid soap fault for soap 1.2 requests

Added:
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml
  (with props)
Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties?rev=1440485&r1=1440484&r2=1440485&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
Wed Jan 30 15:48:24 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/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1440485&r1=1440484&r2=1440485&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Wed Jan 30 15:48:24 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/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java?rev=1440485&r1=1440484&r2=1440485&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
Wed Jan 30 15:48:24 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/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java?rev=1440485&r1=1440484&r2=1440485&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
Wed Jan 30 15:48:24 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/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=1440485&r1=1440484&r2=1440485&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
Wed Jan 30 15:48:24 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/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java?rev=1440485&r1=1440484&r2=1440485&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
Wed Jan 30 15:48:24 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/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java?rev=1440485&r1=1440484&r2=1440485&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Server.java
Wed Jan 30 15:48:24 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/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java?rev=1440485&r1=1440484&r2=1440485&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
Wed Jan 30 15:48:24 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");

Added: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml?rev=1440485&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml
(added)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml
Wed Jan 30 15:48:24 2013
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns5:sayHi
xmlns:ns5="http://apache.org/hello_world_soap_http_soap12/types"/></SOAP-ENV:Body></SOAP-ENV:Envelope>

Propchange: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/sayHiSOAP12Req.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message