cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [2/3] cxf git commit: [CXF-7306] Use prefix passed in the QName of fault subcodes
Date Wed, 02 Aug 2017 15:49:49 GMT
[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/0db60be5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/0db60be5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/0db60be5

Branch: refs/heads/master
Commit: 0db60be561bf758e3dca25d6399125c544caf458
Parents: 894c0a3
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 11:32:02 2017 -0400

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/0db60be5/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 ac96d72..8bf2fc8 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,7 +63,18 @@ 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/0db60be5/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 2e08a56..515588d 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);
@@ -171,7 +171,7 @@ public class SoapFaultSerializerTest extends Assert {
         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