Search in sources :

Example 1 with MUHelperHandler

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

the class TestApp method testMustUnderstand2.

/*
     * MU test here for soap 1.2. Test verifies that the not
     * understood headers are returned to the client as
     * headers in the response message.
     */
public void testMustUnderstand2() throws Exception {
    String next_1_2 = "http://www.w3.org/2003/05/soap-envelope/role/next";
    try {
        // clear handlers (should be none) and add helper handler
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
        MUHelperHandler handler = new MUHelperHandler();
        ClientServerTestUtil.addHandlerToBinding(handler, (BindingProvider) stub);
        // have the handler add two headers
        QName header1 = new QName("urn:mutest", "badheader1");
        QName header2 = new QName("urn:mutest", "badheader2");
        handler.setMUHeader(header1, next_1_2);
        handler.setMUHeader(header2, next_1_2);
        List<QName> expectedHeaders = new ArrayList<QName>();
        expectedHeaders.add(header1);
        expectedHeaders.add(header2);
        handler.setExpectedHeaders(expectedHeaders);
        // make the call
        try {
            stub.echo("have a nice day");
            fail("did not receive any exception");
        } catch (ProtocolException e) {
            if (e instanceof SOAPFaultException) {
            // pass
            } else {
                fail("did not receive soap fault, received: " + e.toString());
            }
        } catch (Exception e) {
            fail("did not receive protocol exception. received " + e.toString());
        }
    } finally {
        // always clear the handlers
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
    }
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) MUHelperHandler(fromwsdl.soap12.fault.client.handlers.MUHelperHandler) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 2 with MUHelperHandler

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

the class TestApp method testMustUnderstand1.

/*
     * MU test here for soap 1.2. Test uses a simple handler
     * on client side to test service with no handlers.
     */
public void testMustUnderstand1() throws Exception {
    String next_1_2 = "http://www.w3.org/2003/05/soap-envelope/role/next";
    try {
        // clear handlers (should be none) and add helper handler
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
        MUHelperHandler handler = new MUHelperHandler();
        ClientServerTestUtil.addHandlerToBinding(handler, (BindingProvider) stub);
        // have handler set header that is ignored
        handler.setMUHeader(new QName("urn:mutest", "someheader"), "notarealactor");
        // make the call
        String arg = "echo";
        assertEquals(arg, stub.echo(arg));
        // add header that should result in soap fault
        handler.setMUHeader(new QName("urn:mutest", "someheader"), next_1_2);
        // make the call
        try {
            stub.echo(arg);
            fail("did not receive any exception");
        } catch (ProtocolException e) {
            if (e instanceof SOAPFaultException) {
            // pass
            } else {
                fail("did not receive soap fault, received: " + e.toString());
            }
        } catch (Exception e) {
            fail("did not receive protocol exception. received " + e.toString());
        }
    } finally {
        // always clear the handlers
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
    }
}
Also used : ProtocolException(jakarta.xml.ws.ProtocolException) QName(javax.xml.namespace.QName) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) MUHelperHandler(fromwsdl.soap12.fault.client.handlers.MUHelperHandler) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Aggregations

MUHelperHandler (fromwsdl.soap12.fault.client.handlers.MUHelperHandler)2 ProtocolException (jakarta.xml.ws.ProtocolException)2 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)2 QName (javax.xml.namespace.QName)2 ArrayList (java.util.ArrayList)1