cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r939243 - /cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
Date Thu, 29 Apr 2010 09:37:59 GMT
Author: ffang
Date: Thu Apr 29 09:37:59 2010
New Revision: 939243

URL: http://svn.apache.org/viewvc?rev=939243&view=rev
Log:
[CXF-2780] Wrong soap fault code thrown on network connection failure

Modified:
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?rev=939243&r1=939242&r2=939243&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
Thu Apr 29 09:37:59 2010
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.endpoint;
 
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -46,6 +47,7 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
 import org.apache.cxf.interceptor.ClientOutFaultObserver;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.interceptor.InterceptorProvider;
@@ -479,9 +481,34 @@ public class ClientImpl
 
             // add additional interceptors and such
             modifyChain(chain, message, false);
-            
-            // execute chain
-            chain.doIntercept(message);
+            try {
+                // execute chain
+                chain.doIntercept(message);
+            } catch (Fault fault) {
+                if (fault.getCause().getCause() instanceof IOException
+                        || fault.getCause() instanceof IOException) {
+                    String soap11NS = "http://schemas.xmlsoap.org/soap/envelope/";
+                    String soap12NS = "http://www.w3.org/2003/05/soap-envelope";
+                    QName faultCode = fault.getFaultCode();
+                    //for SoapFault, if it's underlying cause is IOException, 
+                    //it means something like server is down or can't create 
+                    //connection, according to soap spec we should set fault as
+                    //Server Fault
+                    if (faultCode.getNamespaceURI().equals(
+                            soap11NS)
+                            && faultCode.getLocalPart().equals("Client")) {
+                        faultCode = new QName(soap11NS, "Server");
+                        fault.setFaultCode(faultCode);
+                    }
+                    if (faultCode.getNamespaceURI().equals(
+                            soap12NS)
+                            && faultCode.getLocalPart().equals("Sender")) {
+                        faultCode = new QName(soap12NS, "Receiver");
+                        fault.setFaultCode(faultCode);
+                    }
+                }
+                throw fault;
+            }
 
             return processResult(message, exchange, oi, resContext);
 



Mime
View raw message