Author: klape
Date: 2013-05-10 14:34:51 -0400 (Fri, 10 May 2013)
New Revision: 17544
Modified:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
Log:
Changes for BZ 961561 to allow mutiple subcodes in a SOAP 1.2 fault
Modified:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java 2013-05-10
00:25:30 UTC (rev 17543)
+++
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java 2013-05-10
18:34:51 UTC (rev 17544)
@@ -19,7 +19,9 @@
package org.apache.cxf.binding.soap;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -46,7 +48,7 @@
* FaultHandler) be mapped to "Sender" instead.
*/
- private QName subCode;
+ private List<QName> subCodes;
private String role;
private String node;
private Map<String, String> namespaces = new HashMap<String, String>();
@@ -81,9 +83,13 @@
return getFaultCodeString(prefix, defaultPrefix, getFaultCode());
}
- public String getSubCodeString(String prefix, String defaultPrefix) {
+ public String getSubCodeString(String prefix, String defaultPrefix, QName subCode) {
return getFaultCodeString(prefix, defaultPrefix, subCode);
}
+
+ public String getSubCodeString(String prefix, String defaultPrefix) {
+ return getFaultCodeString(prefix, defaultPrefix, subCodes.get(0));
+ }
private String getFaultCodeString(String prefix, String defaultPrefix, QName fCode)
{
String codePrefix = null;
@@ -135,18 +141,34 @@
* @return The SubCode element as detailed by the SOAP 1.2 spec.
*/
public QName getSubCode() {
- return subCode;
+ if (subCodes != null && subCodes.size() > 0) {
+ return subCodes.get(0);
+ } else {
+ return null;
+ }
}
/**
- * Sets the SubCode for the Fault Code.
+ * Sets the set of sub codes to the one passed in
*
* @param subCode The SubCode element as detailed by the SOAP 1.2 spec.
*/
public void setSubCode(QName subCode) {
- this.subCode = subCode;
+ this.subCodes = new ArrayList<QName>();
+ subCodes.add(subCode);
}
+ public void addSubCode(QName subCode) {
+ if (subCodes == null) {
+ subCodes = new ArrayList<QName>();
+ }
+ subCodes.add(subCode);
+ }
+
+ public List<QName> getSubCodes() {
+ return subCodes;
+ }
+
public Map<String, String> getNamespaces() {
return namespaces;
}
Modified:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java 2013-05-10
00:25:30 UTC (rev 17543)
+++
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java 2013-05-10
18:34:51 UTC (rev 17544)
@@ -19,15 +19,18 @@
package org.apache.cxf.binding.soap.interceptor;
+import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamWriter;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.apache.cxf.binding.soap.Soap11;
import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.binding.soap.SoapMessage;
import
org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor.Soap11FaultOutInterceptorInternal;
@@ -46,7 +49,7 @@
public void handleMessage(SoapMessage message) throws Fault {
Fault f = (Fault) message.getContent(Exception.class);
message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode());
- if (message.getVersion().getVersion() == 1.1) {
+ if (message.getVersion() == Soap11.getInstance()) {
message.getInterceptorChain().add(Soap11FaultOutInterceptorInternal.INSTANCE);
} else {
message.getInterceptorChain().add(Soap12FaultOutInterceptorInternal.INSTANCE);
@@ -91,14 +94,9 @@
defaultPrefix));
writer.writeEndElement();
- if (fault.getSubCode() != null) {
- writer.writeStartElement(defaultPrefix, "Subcode", ns);
- writer.writeStartElement(defaultPrefix, "Value", ns);
-
writer.writeCharacters(fault.getSubCodeString(getFaultCodePrefix(writer,
-
fault.getSubCode()),
- defaultPrefix));
- writer.writeEndElement();
- writer.writeEndElement();
+ if (fault.getSubCodes() != null) {
+ Iterator<QName> subCodes = fault.getSubCodes().iterator();
+ writeSubCodes(writer, fault, subCodes, ns, defaultPrefix);
}
writer.writeEndElement();
@@ -143,6 +141,22 @@
}
}
+ private void writeSubCodes(XMLStreamWriter writer, SoapFault fault,
+ Iterator<QName> subCodes, String ns, String defaultPrefix) throws
Exception {
+ QName subCode = subCodes.next();
+ writer.writeStartElement(defaultPrefix, "Subcode", ns);
+ writer.writeStartElement(defaultPrefix, "Value", ns);
+ writer.writeCharacters(fault.getSubCodeString(getFaultCodePrefix(writer,
+
fault.getSubCode()),
+ defaultPrefix,
+ subCode));
+ writer.writeEndElement();
+ if (subCodes.hasNext()) {
+ writeSubCodes(writer, fault, subCodes, ns, defaultPrefix);
+ }
+ writer.writeEndElement();
+ }
+
private String getLangCode() {
String code = LOG.getResourceBundle().getLocale().getLanguage();
if (StringUtils.isEmpty(code)) {
Modified:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties
===================================================================
---
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties 2013-05-10
00:25:30 UTC (rev 17543)
+++
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/Messages.properties 2013-05-10
18:34:51 UTC (rev 17544)
@@ -26,5 +26,6 @@
ATTACHMENT_NOT_SUPPORTED = Attachments of type {0} are not supported.
DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING = {0} is not valid in {1} mode with SOAP/HTTP
binding.
DISPATCH_OBJECT_NOT_SUPPORTED_XMLBINDING = {0} is not valid in {1} mode with XML/HTTP
binding.
+EXCEPTION_WHILE_ADDING_SUBCODES = There was a problem when adding subcodes.
EXCEPTION_WHILE_WRITING_FAULT = Exception occurred while writing fault.
-CANNOT_SET_HOLDER_OBJECTS = The message content list of the in message and out message
are same, CXF can't set the holder object into the message content list of the out
message.
\ No newline at end of file
+CANNOT_SET_HOLDER_OBJECTS = The message content list of the in message and out message
are same, CXF can't set the holder object into the message content list of the out
message.
Modified:
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java 2013-05-10
00:25:30 UTC (rev 17543)
+++
thirdparty/cxf/branches/cxf-2.4.9.jbossorg-1_BZ961561/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java 2013-05-10
18:34:51 UTC (rev 17544)
@@ -21,6 +21,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Iterator;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -28,7 +29,9 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.ws.WebFault;
+import javax.xml.ws.soap.SOAPFaultException;
+import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.i18n.BundleUtils;
import org.apache.cxf.common.logging.LogUtils;
@@ -83,6 +86,23 @@
return;
}
+ try {
+ if (f.getCause().getClass().equals(SOAPFaultException.class)) {
+ SOAPFaultException sfe = (SOAPFaultException) (f.getCause());
+ if (f.getClass().equals(SoapFault.class)) {
+ SoapFault sf = (SoapFault) f;
+ Iterator iterator = sfe.getFault().getFaultSubcodes();
+ while (iterator.hasNext()) {
+ sf.addSubCode((QName) iterator.next());
+ }
+ }
+ message.setContent(Exception.class, f);
+ }
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "EXCEPTION_WHILE_ADDING_SUBCODES");
+ LOG.log(Level.FINE, "EXCEPTION_WHILE_ADDING_SUBCODES", e);
+ }
+
Throwable cause = f.getCause();
WebFault fault = null;
if (cause != null) {