if (fd != null) {
if (log.isErrorEnabled()) {
log.debug("Marshal as a Service Exception");
}
// Create the JAXB Context
JAXBBlockContext context = new JAXBBlockContext(marshalDesc.getPackages());
// The exception is a Service Exception.
// It may be (A) JAX-WS compliant exception or
// (B) JAX-WS legacy exception
// The faultBeanObject is a JAXB object that represents the data of the exception.
// It is marshalled in the detail section of the soap fault.
// The faultBeanObject is obtained direction from the exception (A) or via
// the legacy exception rules (B).
Object faultBeanObject = null;
FaultBeanDesc faultBeanDesc = marshalDesc.getFaultBeanDesc(fd);
String faultInfo = fd.getFaultInfo();
if (faultInfo == null || faultInfo.length() == 0) {
// Legacy Exception case
faultBeanObject = LegacyExceptionUtil.createFaultBean(t, fd, marshalDesc);
} else {
// Normal case
// Get the fault bean object.
Method getFaultInfo = t.getClass().getMethod("getFaultInfo", null);
faultBeanObject = getFaultInfo.invoke(t, null);
}
if (log.isErrorEnabled()) {
log.debug("The faultBean type is" + faultBeanObject.getClass().getName());
}
// Use "by java type" marshalling if necessary
if (faultBeanObject == t ||
(context.getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE
.BY_CONTEXT_PATH &&
isNotJAXBRootElement(faultBeanObject.getClass(), marshalDesc))) {
context.setProcessType(faultBeanObject.getClass());
}
QName faultBeanQName = new QName(faultBeanDesc.getFaultBeanNamespace(),
faultBeanDesc.getFaultBeanLocalName());
// Make sure the faultBeanObject can be marshalled as an element