cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject svn commit: r1511398 - in /cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/
Date Wed, 07 Aug 2013 16:59:14 GMT
Author: asoldano
Date: Wed Aug  7 16:59:13 2013
New Revision: 1511398

URL: http://svn.apache.org/r1511398
Log:
[CXF-5186] Properly parse soap 1.2 faul reason xml:lang attribute

Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.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=1511398&r1=1511397&r2=1511398&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 Aug  7 16:59:13 2013
@@ -74,6 +74,7 @@ public class Soap12FaultInInterceptor ex
         String role = null;
         String node = null;
         Element detail = null;
+        String lang = null;
 
         Map<String, String> ns = new HashMap<String, String>();
         ns.put("s", Soap12.SOAP_NAMESPACE);
@@ -122,6 +123,10 @@ public class Soap12FaultInInterceptor ex
                                              fault,
                                              XPathConstants.STRING);
             
+            lang = (String) xu.getValue("//s:Fault/s:Reason/s:Text/@xml:lang", 
+                                             fault,
+                                             XPathConstants.STRING);
+            
             Node detailNode = (Node) xu.getValue("//s:Fault/s:Detail",
                                                  fault,
                                                  XPathConstants.NODE);
@@ -152,6 +157,7 @@ public class Soap12FaultInInterceptor ex
         fault.setDetail(detail);
         fault.setRole(role);
         fault.setNode(node);
+        fault.setLang(lang);
         return fault;
     }
 

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=1511398&r1=1511397&r2=1511398&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Wed
Aug  7 16:59:13 2013
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.HttpURLConnection;
+import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.Future;
 import java.util.logging.Logger;
@@ -215,14 +216,20 @@ public class JaxWsClientProxy extends or
                     //ignore
                 }
             }
-            soapFault.setFaultString(((SoapFault)ex).getReason());
+            final boolean isSoap11 = SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(soapFault.getNamespaceURI());
+            
+            if (isSoap11 || ((SoapFault)ex).getLang() == null) {
+                soapFault.setFaultString(((SoapFault)ex).getReason());
+            } else {
+                soapFault.setFaultString(((SoapFault)ex).getReason(), stringToLocale(((SoapFault)ex).getLang()));
+            }
+            
             SAAJUtils.setFaultCode(soapFault, ((SoapFault)ex).getFaultCode());
             String role = ((SoapFault)ex).getRole();
             if (role != null) {
                 soapFault.setFaultActor(role);
             }
-            if (((SoapFault)ex).getSubCodes() != null 
-                && !SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(soapFault.getNamespaceURI()))
{
+            if (((SoapFault)ex).getSubCodes() != null && !isSoap11) {
                 // set the subcode only if it is supported (e.g, 1.2)
                 for (QName fsc : ((SoapFault)ex).getSubCodes()) {
                     soapFault.appendFaultSubcode(fsc);    
@@ -248,6 +255,17 @@ public class JaxWsClientProxy extends or
         }      
         return soapFault;
     }
+    
+    private static Locale stringToLocale(String locale) {
+        String parts[] = locale.split("_", -1);
+        if (parts.length == 1) {
+            return new Locale(parts[0]);
+        } else if (parts.length == 2) {
+            return new Locale(parts[0], parts[1]);
+        } else {
+            return new Locale(parts[0], parts[1], parts[2]);
+        }
+    }
 
     private boolean addressChanged(String address) {
         return !(address == null

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java?rev=1511398&r1=1511397&r2=1511398&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
Wed Aug  7 16:59:13 2013
@@ -101,7 +101,7 @@ public class WebFaultOutInterceptor exte
                     String convertedLang = lang.getLanguage();
                     String country = lang.getCountry();
                     if (country.length() > 0) {
-                        convertedLang = convertedLang + '-' + country;
+                        convertedLang = convertedLang + '_' + country;
                     }
                     f.setLang(convertedLang);
                 }



Mime
View raw message