cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/4] cxf git commit: [CXF-7306] Use prefix passed in the QName of fault subcodes
Date Wed, 02 Aug 2017 16:45:25 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes d8ecd66e0 -> 98c61725f


[CXF-7306] Use prefix passed in the QName of fault subcodes


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

Branch: refs/heads/3.1.x-fixes
Commit: a9075319097cdfa37ab54f04f607c0a062bc4459
Parents: d8ecd66
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue Aug 1 15:45:04 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Aug 2 12:44:10 2017 -0400

----------------------------------------------------------------------
 .../soap/interceptor/AbstractSoapInterceptor.java   | 16 ++++++++++++++--
 .../soap/interceptor/SoapFaultSerializerTest.java   |  8 ++++----
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a9075319/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
index 096ca02..9dcf556 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
@@ -32,6 +32,7 @@ import org.w3c.dom.Element;
 
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
@@ -62,8 +63,19 @@ public abstract class AbstractSoapInterceptor extends AbstractPhaseInterceptor<S
         String codeNs = faultCode.getNamespaceURI();
         String prefix = null;
         if (codeNs.length() > 0) {
-            prefix = StaxUtils.getUniquePrefix(writer, codeNs, true);
-        }        
+            prefix = faultCode.getPrefix();
+            if (!StringUtils.isEmpty(prefix)) {
+                String boundNS = writer.getNamespaceContext().getNamespaceURI(prefix);
+                if (StringUtils.isEmpty(boundNS)) {
+                    writer.writeNamespace(prefix, codeNs);
+                } else if (!codeNs.equals(boundNS)) {
+                    prefix = null;
+                }
+            }
+            if (StringUtils.isEmpty(prefix)) {
+                prefix = StaxUtils.getUniquePrefix(writer, codeNs, true);
+            }
+        }
         return prefix;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/a9075319/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
index 4304c1c..6d8ab71 100644
--- a/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
+++ b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapFaultSerializerTest.java
@@ -144,7 +144,7 @@ public class SoapFaultSerializerTest extends Assert {
         assertValid("//soap12env:Fault/soap12env:Code/soap12env:Value[text()='ns1:Sender']",

                     faultDoc);
         assertValid("//soap12env:Fault/soap12env:Code/soap12env:Subcode/"
-                    + "soap12env:Value[text()='ns2:invalidsoap']", 
+                    + "soap12env:Value[text()='cxffaultcode:invalidsoap']",
                     faultDoc);
         assertValid("//soap12env:Fault/soap12env:Reason/soap12env:Text[@xml:lang='en']",

                     faultDoc);
@@ -170,8 +170,8 @@ public class SoapFaultSerializerTest extends Assert {
     public void testSoap12WithMultipleSubCodesOut() throws Exception {
         String faultString = "Hadrian caused this Fault!";
         SoapFault fault = new SoapFault(faultString, Soap12.getInstance().getSender());
-        
-        fault.addSubCode(new QName("http://cxf.apache.org/soap/fault", "invalidsoap", "cxffaultcode"));
+
+        fault.addSubCode(new QName("http://cxf.apache.org/soap/fault", "invalidsoap"));
         fault.addSubCode(new QName("http://cxf.apache.org/soap/fault2", "invalidsoap2", "cxffaultcode2"));
 
         SoapMessage m = new SoapMessage(new MessageImpl());
@@ -200,7 +200,7 @@ public class SoapFaultSerializerTest extends Assert {
                     + "soap12env:Value[text()='ns2:invalidsoap']", 
                     faultDoc);
         assertValid("//soap12env:Fault/soap12env:Code/soap12env:Subcode/soap12env:Subcode/"
-                    + "soap12env:Value[text()='ns2:invalidsoap2']", 
+                    + "soap12env:Value[text()='cxffaultcode2:invalidsoap2']",
                     faultDoc);
         assertValid("//soap12env:Fault/soap12env:Reason/soap12env:Text[@xml:lang='en']",

                     faultDoc);


Mime
View raw message