I'm doing some validation in custom handler and in case of error sending response back to client from custom handler. However original payload of the client request is also sent back to client. How body can be emptied from response message ? If I debug SoapBody it seems to be empty but still somehow original payload is sent back to client.
Here's my function for sending message back to user.
private void myAuthErrorHandler(MessageContext msgCtx)
{
Axis2MessageContext axis2smc = (Axis2MessageContext) msgCtx;
org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
SOAPBody body = msgCtx.getEnvelope().getBody();
// remove the existing payload
for (Iterator itr = body.getChildElements(); itr.hasNext();) {
OMElement child = (OMElement) itr.next();
child.detach();
}
log.error(""+msgCtx.getEnvelope());
axis2MessageCtx.setProperty("HTTP_SC", "403");
axis2MessageCtx.setProperty("NO_ENTITY_BODY", new Boolean("true"));
axis2MessageCtx.setProperty("RESPONSE", "true");
axis2MessageCtx.setTo(null);
Axis2Sender.sendBack(msgCtx);
}
log.error(""+msgCtx.getEnvelope()); looks to be empty but still original body (payload) is sent back to client.
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body></soapenv:Body></soapenv:Envelope>
Is this possibly a bug or why original body is sent back to client ? Is there's any other methods to clear response body ?
Thanks for any help.