SOAPFault soapFault = sfe.getFault();
if (soapFault == null) {
// No fault ? I will treat this like category E
xmlfault =
new XMLFault(null, // Use the default XMLFaultCode
new XMLFaultReason(
t.toString())); // Assumes text lang of current Locale
} else {
xmlfault = XMLFaultUtils.createXMLFault(soapFault);
}
} else if (t instanceof WebServiceException) {
if (log.isErrorEnabled()) {
log.debug("Marshal as a WebServiceException");
}
// Category D: WebServiceException
// The reason is constructed with the getMessage of the exception.
// There is no detail
WebServiceException wse = (WebServiceException)t;
// Get the fault text using algorithm defined in JAX-WS 10.2.2.3
String text = wse.getMessage();
if (text == null || text.length() == 0) {
text = wse.toString();
}
xmlfault = new XMLFault(null, // Use the default XMLFaultCode
new XMLFaultReason(
text)); // Assumes text lang of current Locale
} else {
if (log.isErrorEnabled()) {
log.debug("Marshal as a unchecked System Exception");
}
// Category E: Other System Exception
// The reason is constructed with the toString of the exception.
// This places the class name of the exception in the reason
// There is no detail.
// Get the fault text using algorithm defined in JAX-WS 10.2.2.3
String text = t.getMessage();
if (text == null || text.length() == 0) {
text = t.toString();
}
xmlfault = new XMLFault(null, // Use the default XMLFaultCode
new XMLFaultReason(
text)); // Assumes text lang of current Locale
}
return xmlfault;
} catch (Throwable e) {
try {
// If an exception occurs while demarshalling an exception,
// then rinse and repeat with a webservice exception
if (log.isDebugEnabled()) {
log.debug("An exception (" + e + ") occurred while marshalling exception (" +
t + ")");
}
// Get the fault text using algorithm defined in JAX-WS 10.2.2.3
String text = e.getMessage();
if (text == null || text.length() == 0) {
text = e.toString();
}
WebServiceException wse = ExceptionFactory.makeWebServiceException(e);
return new XMLFault(null, // Use the default XMLFaultCode
new XMLFaultReason(
text)); // Assumes text lang of current Locale
} catch (Exception e2) {
// Exception while creating Exception for Exception
throw ExceptionFactory.makeWebServiceException(e2);
}