cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/3] cxf git commit: [CXF-6919] For soap 1.2, make sure the fault code is valid
Date Wed, 05 Apr 2017 19:18:46 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes b94ebcca7 -> 53e7752ff


[CXF-6919] For soap 1.2, make sure the fault code is valid


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/69247884
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/69247884
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/69247884

Branch: refs/heads/3.0.x-fixes
Commit: 6924788445ce33477162dd6076afe683c78babe2
Parents: b94ebcc
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Apr 5 11:29:05 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Apr 5 15:18:36 2017 -0400

----------------------------------------------------------------------
 .../apache/cxf/binding/soap/saaj/SAAJUtils.java | 37 ++++++++++++++------
 1 file changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/69247884/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
index 89cb7f7..0215519 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
@@ -21,12 +21,14 @@ package org.apache.cxf.binding.soap.saaj;
 
 import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
 import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPMessage;
 
+import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.common.util.StringUtils;
 
 /**
@@ -52,20 +54,33 @@ public final class SAAJUtils {
             return m.getSOAPPart().getEnvelope().getBody();
         }
     }
+    
     public static void setFaultCode(SOAPFault f, QName code) throws SOAPException {
-        try {
-            f.setFaultCode(code);
-        } catch (Throwable t) {
-            int count = 1;
-            String pfx = "fc1";
-            while (!StringUtils.isEmpty(f.getNamespaceURI(pfx))) {
-                count++;
-                pfx = "fc" + count;
+        if (f.getNamespaceURI().equals(Soap12.SOAP_NAMESPACE)) {
+            try {
+                f.setFaultCode(code);
+            } catch (SOAPException ex) {
+                f.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
+                f.appendFaultSubcode(code);
+            }
+        } else {
+            try {
+                f.setFaultCode(code);
+            } catch (Throwable t) {
+                int count = 1;
+                String pfx = "fc1";
+                while (!StringUtils.isEmpty(f.getNamespaceURI(pfx))) {
+                    count++;
+                    pfx = "fc" + count;
+                }
+                if (code.getNamespaceURI() != null && !"".equals(code.getNamespaceURI()))
{
+                    f.addNamespaceDeclaration(pfx, code.getNamespaceURI());
+                } else {
+                    f.addNamespaceDeclaration(pfx, f.getNamespaceURI());
+                }
+                f.setFaultCode(pfx + ":" + code.getLocalPart());
             }
-            f.addNamespaceDeclaration(pfx, code.getNamespaceURI());
-            f.setFaultCode(pfx + ":" + code.getLocalPart());
         }
-        
     }
     
     public static SOAPElement adjustPrefix(SOAPElement e, String prefix) {


Mime
View raw message