I have a SOAP handle class and I added a statement to throw a custom runtime exception (first throwing throw new IntrusionException, then catching it, then throwing MyRuntimeException).
According to http://docs.oracle.com/cd/E13222_01/wls/docs103/webserv_adv/handlers.html in the "Implementing the Handler.handleMessage() Method" section, if I throw a runtime exception in the handler, handleFault() should be called.
I put in breakpoints in my application, and that method isn't being called. Instead of a Soap Fault, the client gets the usual response from the WS Also, for some reason, the logging stopped working and in the debugging doesn't stop at the WS class breakpoints, but as soon as i take that throw exception statement out again, the logging works again.
public class GatewayRequestHandler implements javax.xml.ws.handler.soap.SOAPHandler<SOAPMessageContext> {
// private static final Log LOG =
// LogFactory.getLog(GatewayRequestHandler.class);
private static final Logger LOG = ESAPI.getLogger(GatewayRequestHandler.class.getName());
private static myEsapiValidator esapiValidator = (myEsapiValidator) ESAPI.validator();
@Override
public boolean handleMessage(SOAPMessageContext mc) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
String outString = null;
SOAPMessage soapMsg = mc.getMessage();
try {
LOG.info(Logger.EVENT_UNSPECIFIED, "WSDL Operation: " + mc.get(MessageContext.WSDL_OPERATION));
soapMsg.writeTo(outStream);
outString = new String(outStream.toByteArray(), "UTF-8");
// validate inbound message
try {
outString = esapiValidator.getValidInput("ResponseDocument", outString, "my.XMLString",
Integer.MAX_VALUE, true, true);
LOG.info(Logger.SECURITY_SUCCESS, "Successfully validated inbound message.");
throw new IntrusionException("Test canonicalization failure","test");
} catch (IntrusionException | ValidationException e) {
String errStr = "Error validating the inbound response message.";
LOG.error(Logger.SECURITY_FAILURE, errStr, e);
// throw new ComponentException(errStr, e);
throw new MyRuntimeException(errStr, e);
}
... @Override public boolean handleFault(SOAPMessageContext mc) {