* @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 = "";
Throwable exception;
if (faultCode != null) {
fault.setCode((SOAPFaultCode) faultCode);
} else if (soapException != null) {
soapFaultCode = soapException.getFaultCode();
} else
if (((exception = e) instanceof AxisFault || (exception = e.getCause()) instanceof AxisFault))
{
QName faultCodeQName = ((AxisFault) exception).getFaultCode();
if (faultCodeQName != null) {
if (faultCodeQName.getLocalPart().indexOf(":") == -1) {
String prefix = faultCodeQName.getPrefix();
String uri = faultCodeQName.getNamespaceURI();
prefix = prefix == null || "".equals(prefix) ? Constants.AXIS2_NAMESPACE_PREFIX : prefix;
uri = uri == null || "".equals(uri) ? Constants.AXIS2_NAMESPACE_URI : uri;
soapFaultCode = prefix + ":" + faultCodeQName.getLocalPart();
fault.declareNamespace(uri, prefix);
} else {
soapFaultCode = faultCodeQName.getLocalPart();
}
}
}
// defaulting to fault code Sender, if no message is available
if (faultCode == null) {
soapFaultCode = ("".equals(soapFaultCode) || (soapFaultCode == null))
? getSenderFaultCode(context.getEnvelope().getNamespace())
: 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);
message = fault.getReason().getSOAPText().getText();
} else if (soapException != null) {
message = soapException.getMessage();
} else
if (((exception = e) instanceof AxisFault || (exception = e.getCause()) instanceof AxisFault))
{
message = ((AxisFault) exception).getReason();
message = message != null && "".equals(message) ? message : e.getMessage();