Search in sources :

Example 11 with Handler

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

the class BindingTest method testBindingInstances.

/*
     * Used for testing of handlers shared between bindings.
     */
public void testBindingInstances() throws Exception {
    TestService_Service service = getService();
    TestService stub1 = getTestStub(service);
    TestService stub2 = getTestStub(service);
    // make some calls
    stub1.testInt(0);
    stub2.testInt(0);
    Binding b1 = ((BindingProvider) stub1).getBinding();
    Binding b2 = ((BindingProvider) stub2).getBinding();
    List<Handler> chain = b1.getHandlerChain();
    // get a soap handler from the chain. doesn't matter which one
    BaseSOAPHandler handler = null;
    for (Handler h : chain) {
        if (h instanceof BaseSOAPHandler) {
            handler = (BaseSOAPHandler) h;
            break;
        }
    }
    assertTrue("handler should be in 'ready' state", handler.isAvailable());
    b2.setHandlerChain(new ArrayList<Handler>());
    assertTrue("handler should be in 'ready' state", handler.isAvailable());
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) BaseSOAPHandler(handler.handler_processing.common.BaseSOAPHandler) Handler(jakarta.xml.ws.handler.Handler) BaseSOAPHandler(handler.handler_processing.common.BaseSOAPHandler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 12 with Handler

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

the class HandlerClient method test2.

// public void testDispatch1() throws Exception {
// int x = 1; // what we send
// int diff = 2; // 4 handler invocations
// 
// JAXBContext jxbContext = JAXBContext.newInstance(ObjectFactory.class);
// Dispatch dispatch = createDispatchForJAXB(
// new QName("urn:test", "HelloPort"), jxbContext);
// 
// Hello_Type request = objectFactory.createHello_Type();
// request.setValue(1);
// 
// // make first call with no client side handlers
// HelloResponse response = (HelloResponse) dispatch.invoke(request);
// assertNotNull("response cannot be null", response);
// 
// int y = response.getValue();
// System.out.println("sent: " + x + ", expect " + (x+diff) +
// " back. received: " + y);
// assertTrue(y == x+diff);
// 
// System.out.println("now adding handler to dispatch");
// Binding binding = dispatch.getBinding();
// assertNotNull("binding cannot be null", binding);
// int handlerChainLength = binding.getHandlerChain().size();
// assertEquals("the handler list is not empty", 0, handlerChainLength);
// 
// // add handler
// HandlerInfo hInfo = new HandlerInfo(
// handler_tests.simple_handler_test.client.handlers.ClientHandler.class,
// null, null);
// List<HandlerInfo> newHandlers = new ArrayList<HandlerInfo>();
// newHandlers.add(hInfo);
// binding.setHandlerChain(newHandlers);
// 
// // now try again
// diff = 4;
// response = (HelloResponse) dispatch.invoke(request);
// assertNotNull("response cannot be null", response);
// 
// y = response.getValue();
// System.out.println("sent: " + x + ", expect " + (x+diff) +
// " back. received: " + y);
// assertTrue(y == x+diff);
// }
/*
     * Test tries to add a handler programmatically after clearing
     * handlers out of registry in the service.
     */
public void test2() 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 = 6;
    int y = stub.hello(x);
    System.out.println("sent: " + x + ", expect " + (x + diff) + " back. received: " + y);
    assertEquals("handlers not invoked correctly", x + diff, y);
    // now add client handler
    service.setHandlerResolver(new HandlerResolver() {

        public List<Handler> getHandlerChain(PortInfo info) {
            List handlers = new ArrayList<Handler>();
            handlers.add(new TestHandler());
            return handlers;
        }
    });
    stub = createStub(service);
    // test again
    diff = 8;
    y = stub.hello(x);
    System.out.println("sent: " + x + ", expect " + (x + diff) + " back. received: " + y);
    assertEquals("handlers not invoked correctly", x + diff, y);
}
Also used : PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) TestHandler(fromwsdl.handler_dd.common.TestHandler) Handler(jakarta.xml.ws.handler.Handler) TestHandler(fromwsdl.handler_dd.common.TestHandler) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with Handler

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

the class HandlerClient method testLogicalJAXB.

/*
     * Test removes the static handler and adds a logical
     * handler that uses JAXB to change the message.
     */
public void testLogicalJAXB() throws Exception {
    Hello stub = createStub();
    Binding binding = ((BindingProvider) stub).getBinding();
    LogicalTestHandler handler = new LogicalTestHandler();
    handler.setHandleMode(LogicalTestHandler.HandleMode.JAXB);
    List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.add(handler);
    binding.setHandlerChain(handlerChain);
    int x = 1;
    // 2 per handler invoked
    int diff = 4;
    int y = stub.hello(x);
    // x+4 with all handlers
    assertEquals(x + diff, y);
}
Also used : Binding(jakarta.xml.ws.Binding) ArrayList(java.util.ArrayList) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 14 with Handler

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

the class HandlerClient method testDynamic2.

/*
     * Test tries to add a handler programmatically after clearing
     * handlers out of the service. Adds handler using HandlerResolver.
     * Uses a null HandlerResolver to clear the service.
     */
public void testDynamic2() throws Exception {
    Hello_Service service = createService();
    service.setHandlerResolver(null);
    Hello stub = createStub(service);
    int x = 1;
    // 2 per handler invoked
    int diff = 2;
    int y = stub.hello(x);
    assertEquals(x + diff, y);
    // now add client handler
    service.setHandlerResolver(new HandlerResolver() {

        public List<Handler> getHandlerChain(PortInfo info) {
            List list = new ArrayList<Handler>();
            list.add(new SOAPTestHandler());
            return list;
        }
    });
    stub = createStub(service);
    // test again
    diff = 4;
    y = stub.hello(x);
    assertTrue(y == x + diff);
}
Also used : PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with Handler

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

the class HandlerClient method testLogicalGetSourceOnly.

/*
     * Test removes the static handler and adds a logical
     * handler that gets the source but does not change it.
     */
public void testLogicalGetSourceOnly() throws Exception {
    Hello stub = createStub();
    Binding binding = ((BindingProvider) stub).getBinding();
    LogicalTestHandler handler = new LogicalTestHandler();
    handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE_NO_CHANGE);
    List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.add(handler);
    binding.setHandlerChain(handlerChain);
    int x = 1;
    // 2 per handler invoked
    int diff = 2;
    int y = stub.hello(x);
    assertEquals(x + diff, y);
}
Also used : Binding(jakarta.xml.ws.Binding) ArrayList(java.util.ArrayList) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) 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