Search in sources :

Example 16 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.common.SOAPTestHandler) ArrayList(java.util.ArrayList) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) 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 17 with Handler

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

the class BindingTester method testBindingInstances.

/*
     * get the binding object on dispatch object
     */
// public void testDispatch1() throws Exception {
// Dispatch dispatch = createDispatchForSource(
// new QName("urn:test", "TestServicePort"));
// assertNotNull("dispatch object is null", dispatch);
// Binding binding = dispatch.getBinding();
// assertNotNull("binding object should not be null", binding);
// List handlers = binding.getHandlerChain();
// assertNotNull("handler list should not be null", handlers);
// assertTrue("There should be no handlers in list", handlers.size() == 0);
// }
/*
     * 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(fromwsdl.handler.common.BaseSOAPHandler) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 18 with Handler

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

the class EndToEndTester method testResponsePropertyDispatch.

/*
     * Sets a property on the (client side) response handler context
     * and verifies that the client sees it in the response context.
     * This version uses a dispatch client rather than proxy.
     */
public void testResponsePropertyDispatch() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    Dispatch<Object> dispatch = getDispatchJAXB(testPortQName);
    // tell the server handlers not to do anything
    ReportService reportStub = getReportStub(getService());
    reportStub.clearHandlerTracker();
    // add handler
    String myHandlerName = "MyDispatchHandler";
    BaseSOAPHandler propAddingHandler = new BaseSOAPHandler();
    propAddingHandler.setName(CLIENT_PREFIX + myHandlerName);
    propAddingHandler.initTheHandler();
    List<Handler> newHandlers = new ArrayList<Handler>();
    newHandlers.add(propAddingHandler);
    dispatch.getBinding().setHandlerChain(newHandlers);
    // tell the client handlers what to do
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + myHandlerName, HA_ADD_USER_PROPERTY_INBOUND);
    int x = 1;
    TestInt request = new TestInt();
    request.setIntin(x);
    TestIntResponse response = (TestIntResponse) dispatch.invoke(request);
    assertEquals("did not get proper response", x, response.getIntout());
    Map context = dispatch.getResponseContext();
    Object testValue = context.get(USER_HANDLER_PROPERTY_NAME);
    assertNotNull("did not receive property in response context", testValue);
    String testValueString = (String) testValue;
    assertTrue("property value incorrect. expected ", testValueString.equals(USER_PROPERTY_HANDLER_SET));
}
Also used : HandlerTracker(fromwsdl.handler.common.HandlerTracker) ArrayList(java.util.ArrayList) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) AsyncHandler(jakarta.xml.ws.AsyncHandler) Handler(jakarta.xml.ws.handler.Handler) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) HashMap(java.util.HashMap) Map(java.util.Map)

Example 19 with Handler

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

the class HandlerChainTester method testHandlersOnTestPort2.

public void testHandlersOnTestPort2() {
    TestService_Service service = getService();
    TestService testStub = service.getPort(TestService.class);
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    List<Handler> chain = testBinding.getHandlerChain();
    // System.out.println(chain.size());
    assertEquals(3, chain.size());
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 20 with Handler

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

the class HandlerChainTester method testHandlersOnTestPort3.

public void testHandlersOnTestPort3() {
    Service service = Service.create(WSDL_LOCATION, TESTSERVICE);
    TestService testStub = service.getPort(TESTSERVICEPORT, TestService.class);
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    List<Handler> chain = testBinding.getHandlerChain();
    // System.out.println(chain.size());
    assertEquals(0, chain.size());
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) Service(jakarta.xml.ws.Service) 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