* @param fault
* @param e
*/
private void extractFaultInformationFromMessageContext(MessageContext context, SOAPFault fault,
Throwable e) {
SOAPProcessingException soapException = null;
String soapNamespaceURI;
// get the current SOAP version
if (!context.isSOAP11()) {
// defaulting to SOAP 1.2
soapNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
} else {
soapNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
}
if (e instanceof SOAPProcessingException) {
soapException = (SOAPProcessingException) e;
} else if (e instanceof AxisFault) {
if (e.getCause() instanceof SOAPProcessingException) {
soapException = (SOAPProcessingException) e.getCause();
}
} else {
// we have recd an instance of just the Exception class
}
Object faultCode = context.getProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME);
String soapFaultCode = "";
if (faultCode != null) {
fault.setCode((SOAPFaultCode) faultCode);
} else if (soapException != null) {
soapFaultCode = soapException.getFaultCode();
} else if (e instanceof AxisFault) {
soapFaultCode = ((AxisFault) e).getFaultCode();
}
// defaulting to fault code Sender, if no message is available
soapFaultCode = ("".equals(soapFaultCode) || (soapFaultCode == null))
? getSenderFaultCode(soapNamespaceURI)
: soapFaultCode;
fault.getCode().getValue().setText(soapFaultCode);
Object faultReason = context.getProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME);
String message = "";
if (faultReason != null) {
fault.setReason((SOAPFaultReason) faultReason);
} else if (soapException != null) {
message = soapException.getMessage();
} else if (e instanceof AxisFault) {
message = e.getMessage();
}
// defaulting to reason, unknown, if no reason is available