Search in sources :

Example 36 with Binding

use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.

the class BindingTest method testBinding1.

/*
     * test the binding objects for the right number of handlers
     */
public void testBinding1() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    // get the bindings
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    Binding reportBinding = ((BindingProvider) reportStub).getBinding();
    assertNotNull("Binding object should not be null", testBinding);
    assertNotNull("Binding object should not be null", reportBinding);
    // check the handlers
    List<Handler> testHandlers = testBinding.getHandlerChain();
    List<Handler> reportHandlers = reportBinding.getHandlerChain();
    assertNotNull("Handler list should not be null", testHandlers);
    assertNotNull("Handler list should not be null", reportHandlers);
    // check number of handlers
    assertEquals("got wrong number of handlers in test binding", SERVICE_HANDLERS + TEST_PORT_HANDLERS + PROTOCOL_HANDLERS, testHandlers.size());
    assertEquals("got wrong number of handlers in report binding", SERVICE_HANDLERS + REPORT_PORT_HANDLERS + PROTOCOL_HANDLERS, reportHandlers.size());
    // check handler names -- see config file for order
    int[] testNames = { 4, 0, 5, 1, 7, 3 };
    int[] reportNames = { 4, 0, 2, 6, 7, 3 };
    String foundName = null;
    for (int i = 0; i < testNames.length; i++) {
        foundName = ((HasName) testHandlers.get(i)).getName();
        assertEquals("found unexpected handler in chain", CLIENT_PREFIX + testNames[i], foundName);
    }
    for (int i = 0; i < reportNames.length; i++) {
        foundName = ((HasName) reportHandlers.get(i)).getName();
        assertEquals("found unexpected handler in chain", CLIENT_PREFIX + reportNames[i], foundName);
    }
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler) BaseSOAPHandler(handler.handler_processing.common.BaseSOAPHandler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 37 with Binding

use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.

the class EndToEndErrorTest method testServiceSpecificException1.

/*
     * Have the endpoint throw a service specific exception and make
     * sure that the client gets it back. Test case for bug 6232002.
     */
public void testServiceSpecificException1() throws Exception {
    TestService_Service service = getService();
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    // get stubs and clear the trackers
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    reportStub.clearHandlerTracker();
    tracker.clearAll();
    try {
        testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
        fail("did not receive exception (1)");
    } catch (MyFaultException mfe) {
    // passed
    } catch (Exception e) {
        fail("did not receive MyFaultException (1), received " + e);
    }
    // check closed handlers to be sure
    List<String> actualClosed = tracker.getClosedHandlers();
    int[] closed = { 7, 5, 4, 3, 1, 0 };
    assertEquals("Did not get proper number of closed handlers", closed.length, actualClosed.size());
    for (int i = 0; i < closed.length; i++) {
        assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], actualClosed.get(i));
    }
    // remove all client handlers and try again
    Binding binding = ((BindingProvider) testStub).getBinding();
    binding.setHandlerChain(new ArrayList<Handler>());
    tracker.clearAll();
    try {
        testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
        fail("did not receive exception (2)");
    } catch (MyFaultException mfe) {
    // passed
    } catch (Exception e) {
        fail("did not receive MyFaultException (2), received " + e);
    }
    // this just makes sure there really were no handlers
    actualClosed = tracker.getClosedHandlers();
    assertTrue("should not have been closed handlers", actualClosed.isEmpty());
}
Also used : Binding(jakarta.xml.ws.Binding) HandlerTracker(handler.handler_processing.common.HandlerTracker) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) WebServiceException(jakarta.xml.ws.WebServiceException)

Aggregations

Binding (jakarta.xml.ws.Binding)37 BindingProvider (jakarta.xml.ws.BindingProvider)32 Handler (jakarta.xml.ws.handler.Handler)30 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)17 ArrayList (java.util.ArrayList)8 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)5 Service (jakarta.xml.ws.Service)5 WebServiceException (jakarta.xml.ws.WebServiceException)5 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)4 HTTPBinding (jakarta.xml.ws.http.HTTPBinding)4 Source (javax.xml.transform.Source)3 BaseSOAPHandler (fromwsdl.handler.common.BaseSOAPHandler)2 BaseSOAPHandler (handler.handler_processing.common.BaseSOAPHandler)2 ProtocolException (jakarta.xml.ws.ProtocolException)2 HandlerResolver (jakarta.xml.ws.handler.HandlerResolver)2 PortInfo (jakarta.xml.ws.handler.PortInfo)2 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Localizable (com.sun.istack.localization.Localizable)1