抛出异常时未调用SOAP Handler Fault

时间:2015-10-28 18:21:45

标签: java eclipse soap soaphandler

我有一个SOAP句柄类,我添加了一个语句来抛出自定义运行时异常(首先抛出新的IntrusionException,然后捕获它,然后抛出MyRuntimeException)。

根据“实现Handler.handleMessage()方法”一节中的http://docs.oracle.com/cd/E13222_01/wls/docs103/webserv_adv/handlers.html,如果我在处理程序中抛出运行时异常,则应调用handleFault()。

我在我的应用程序中放入了断点,并且没有调用该方法。而不是Soap Fault,客户端从WS获得通常的响应。此外,由于某种原因,日志记录停止工作,并且在调试中不会停止在WS类断点处,但是只要我将该throw异常语句取出再次,伐木再次起作用。

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);
                        }

...         @覆盖         public boolean handleFault(SOAPMessageContext mc){

0 个答案:

没有答案