// If the result is from an InvocationTargetException look at
// the actual cause.
if (result instanceof InvocationTargetException) {
result = ((InvocationTargetException)result).getCause();
}
DataType targetDataType = null;
for (DataType exType : targetOperation.getFaultTypes()) {
if (((Class)exType.getPhysical()).isInstance(result)) {
if (result instanceof FaultException) {
DataType faultType = (DataType)exType.getLogical();
if (((FaultException)result).isMatchingType(faultType.getLogical())) {
targetDataType = exType;
break;
}
} else {
targetDataType = exType;
break;
}
}
}
/*
if (targetDataType == null) {
// Not a business exception
return resultMsg;
}
*/
DataType targetFaultType = getFaultType(targetDataType);
if (targetFaultType == null) {
throw new ServiceRuntimeException("Target fault type cannot be resolved: " + targetDataType,
(Throwable)result);
// throw new TransformationException("Target fault type cannot be resolved: " + targetDataType);
}
// FIXME: How to match a source fault type to a target fault
// type?
DataType sourceDataType = null;
DataType sourceFaultType = null;
for (DataType exType : sourceOperation.getFaultTypes()) {
DataType faultType = getFaultType(exType);
// Match by the QName (XSD element) of the fault type
if (faultType != null && typesMatch(targetFaultType.getLogical(), faultType.getLogical())) {
sourceDataType = exType;
sourceFaultType = faultType;
break;
}
}