For soap 1.2, make sure the fault code is valid
@@ -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,7 +54,16 @@ public final class SAAJUtils {
return m.getSOAPPart().getEnvelope().getBody();
}
}
+
public static void setFaultCode(SOAPFault f, QName code) throws SOAPException {
+ 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) {
@@ -69,7 +80,7 @@ public final class SAAJUtils {
}
f.setFaultCode(pfx + ":" + code.getLocalPart());
}
-
+ }
}
public static SOAPElement adjustPrefix(SOAPElement e, String prefix) {
