}
}
workerPool.execute( new Runnable() {
public void run() {
MessageReceiver mr = mc.getAxisOperation().getMessageReceiver();
try {
// This AxisFault is created to create the fault message context
// noinspection ThrowableInstanceNeverThrown
AxisFault axisFault = exceptionToRaise != null ?
new AxisFault(errorMessage, exceptionToRaise) :
new AxisFault(errorMessage);
MessageContext nioFaultMessageContext =
MessageContextBuilder.createFaultMessageContext(mc, axisFault);
SOAPEnvelope envelope = nioFaultMessageContext.getEnvelope();
if (log.isDebugEnabled()) {
log.debug("Sending Fault for Request with Message ID : "
+ mc.getMessageID());
}
nioFaultMessageContext.setProperty(
NhttpConstants.SENDING_FAULT, Boolean.TRUE);
nioFaultMessageContext.setProperty(
NhttpConstants.ERROR_MESSAGE, errorMessage);
if (errorCode != -1) {
nioFaultMessageContext.setProperty(
NhttpConstants.ERROR_CODE, errorCode);
}
if (exceptionToRaise != null) {
nioFaultMessageContext.setProperty(
NhttpConstants.ERROR_DETAIL, exceptionToRaise.toString());
nioFaultMessageContext.setProperty(
NhttpConstants.ERROR_EXCEPTION, exceptionToRaise);
envelope.getBody().getFault().getDetail().setText(
exceptionToRaise.toString());
} else {
nioFaultMessageContext.setProperty(
NhttpConstants.ERROR_DETAIL, errorMessage);
envelope.getBody().getFault().getDetail().setText(errorMessage);
}
nioFaultMessageContext.setProperty(CLIENT_CONNECTION_DEBUG,
mc.getProperty(CLIENT_CONNECTION_DEBUG));
mr.receive(nioFaultMessageContext);
} catch (AxisFault af) {
log.error("Unable to report back failure to the message receiver", af);
}
}