Search in sources :

Example 1 with ExceptionThrowingHandler

use of fromwsdl.soap12.fault.client.handlers.ExceptionThrowingHandler in project metro-jax-ws by eclipse-ee4j.

the class TestApp method testHandlerException1.

/**
 * Have a handler throw a protocol exception and make sure
 * the proper values are in the soap fault. Test for 6353191.
 */
public void testHandlerException1() throws Exception {
    // the expected fault code local part
    String code = "Sender";
    try {
        // clear handlers (should be none) and add helper handler
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
        ExceptionThrowingHandler handler = new ExceptionThrowingHandler("ProtocolException");
        ClientServerTestUtil.addHandlerToBinding(handler, (BindingProvider) stub);
        // make the call
        try {
            stub.echo("have a nice day");
            fail("did not receive any exception");
        } catch (SOAPFaultException e) {
            SOAPFault fault = e.getFault();
            String faultCode = fault.getFaultCode();
            assertTrue("fault code should end with \"" + code + "\": " + faultCode, faultCode.endsWith(code));
        } catch (Exception e) {
            fail("did not receive soap fault exception. received " + e.toString());
        }
    } finally {
        // always clear the handlers
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
    }
}
Also used : SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) SOAPFault(jakarta.xml.soap.SOAPFault) ExceptionThrowingHandler(fromwsdl.soap12.fault.client.handlers.ExceptionThrowingHandler) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Aggregations

ExceptionThrowingHandler (fromwsdl.soap12.fault.client.handlers.ExceptionThrowingHandler)1 SOAPFault (jakarta.xml.soap.SOAPFault)1 ProtocolException (jakarta.xml.ws.ProtocolException)1 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)1