Search in sources :

Example 6 with Handler

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

the class HandlerClient method testDynamic1.

/*
     * Test tries to add a handler programmatically after clearing
     * handlers out of the service. Adds handler to binding. Uses
     * an empty handler resolver for clearing the service.
     */
public void testDynamic1() throws Exception {
    Hello_Service service = createService();
    service.setHandlerResolver(new HandlerResolver() {

        public List<Handler> getHandlerChain(PortInfo info) {
            return new ArrayList<Handler>();
        }
    });
    Hello stub = createStub(service);
    int x = 1;
    // 2 per handler invoked
    int diff = 2;
    int y = stub.hello(x);
    assertTrue(y == x + diff);
    // now add client handler
    List<Handler> handlerList = new ArrayList<Handler>();
    handlerList.add(new SOAPTestHandler());
    Binding binding = ((BindingProvider) stub).getBinding();
    binding.setHandlerChain(handlerList);
    // test again
    diff = 4;
    y = stub.hello(x);
    assertTrue(y == x + diff);
}
Also used : Binding(jakarta.xml.ws.Binding) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) ArrayList(java.util.ArrayList) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider) PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with Handler

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

the class HandlerClient method testSOAP12Binding1.

/*
     * The normal tests in this file are for soap 1.1. This is a soap 1.2
     * test to make sure that the port is created with the proper binding
     * so that the proper handlers are called. See bug 6353179.
     *
     * Not working right now -- can't get endpoint to work.
     */
public void testSOAP12Binding1() throws Exception {
    Hello_Service service = createService();
    Hello12 stub = create12Stub(service);
    // make sure port is working
    int x = 1;
    // server handler only
    int diff = 2;
    int y = stub.hello12(x);
    assertEquals(x + diff, y);
    Binding binding = ((BindingProvider) stub).getBinding();
    List<Handler> handlers = binding.getHandlerChain();
    assertEquals("should be 1 handler in chain", 1, handlers.size());
    Handler handler = handlers.get(0);
    assertTrue("handler should be type Port12Handler, not " + handler.getClass().toString(), handler instanceof Port12Handler);
    Port12Handler p12h = (Port12Handler) handler;
    p12h.resetCalled();
    stub.hello12(2);
    assertEquals("handler should have been called two times", 2, p12h.getCalled());
}
Also used : Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 8 with Handler

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

the class ClientServerTestUtil method clearHandlers.

/**
 * Method used to clear any handlers from a stub or dispatch object.
 */
public static void clearHandlers(BindingProvider provider) {
    Binding binding = provider.getBinding();
    binding.setHandlerChain(new ArrayList<Handler>());
}
Also used : Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler)

Example 9 with Handler

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

the class ClientServerTestUtil method addHandlerToBinding.

/**
 * Method used to add a Handler to a stub or dispatch object.
 */
public static void addHandlerToBinding(Handler handler, BindingProvider bindingProvider) {
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlers = binding.getHandlerChain();
    handlers.add(handler);
    binding.setHandlerChain(handlers);
}
Also used : Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler)

Example 10 with Handler

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

the class Util method addHandler.

// utility methods to be made available to the test clients
/**
 * Method used to add a Handler to a stub or dispatch object.
 */
public static void addHandler(Handler handler, Object provider) {
    BindingProvider bindingProvider = (BindingProvider) provider;
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlers = binding.getHandlerChain();
    handlers.add(handler);
    binding.setHandlerChain(handlers);
}
Also used : Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Aggregations

Handler (jakarta.xml.ws.handler.Handler)43 Binding (jakarta.xml.ws.Binding)30 BindingProvider (jakarta.xml.ws.BindingProvider)28 ArrayList (java.util.ArrayList)18 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)15 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)7 Service (jakarta.xml.ws.Service)7 List (java.util.List)7 HandlerResolver (jakarta.xml.ws.handler.HandlerResolver)6 PortInfo (jakarta.xml.ws.handler.PortInfo)6 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)5 BaseSOAPHandler (fromwsdl.handler.common.BaseSOAPHandler)4 WebServiceException (jakarta.xml.ws.WebServiceException)4 Source (javax.xml.transform.Source)4 HandlerTracker (fromwsdl.handler.common.HandlerTracker)3 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)3 HandlerAnnotationInfo (com.sun.xml.ws.util.HandlerAnnotationInfo)2 BaseSOAPHandler (handler.handler_processing.common.BaseSOAPHandler)2 SOAPMessage (jakarta.xml.soap.SOAPMessage)2 AsyncHandler (jakarta.xml.ws.AsyncHandler)2