Search in sources :

Example 26 with BindingProvider

use of jakarta.xml.ws.BindingProvider 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 27 with BindingProvider

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

the class EndToEndTester method testResponseProperty.

/*
     * Sets a property on the (client side) response handler context
     * and verifies that the client sees it in the response context.
     */
public void testResponseProperty() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService stub = getTestStub(getService());
    tracker.clearAll();
    tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_ADD_USER_PROPERTY_INBOUND);
    stub.testInt(1);
    Map context = ((BindingProvider) stub).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) BindingProvider(jakarta.xml.ws.BindingProvider) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with BindingProvider

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

the class EndToEndTester method testClientRequestAndResponseProperties.

/*
     * Verifies that properties exist in request and response. Also
     * combines some of the above request and response tests.
     */
public void testClientRequestAndResponseProperties() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    TestService stub = getTestStub(getService());
    ((BindingProvider) stub).getRequestContext().put(USER_CLIENT_PROPERTY_NAME, USER_PROPERTY_CLIENT_SET);
    tracker.clearAll();
    // handler looks for client prop in request
    tracker.setHandlerAction(CLIENT_PREFIX + 5, HA_CHECK_FOR_USER_PROPERTY_OUTBOUND);
    // handler adds another prop during request
    tracker.setHandlerAction(CLIENT_PREFIX + 7, HA_ADD_USER_PROPERTY_OUTBOUND);
    // handler checks for both props and adds third
    tracker.setHandlerAction(CLIENT_PREFIX + 3, HA_ADD_AND_CHECK_PROPS_INBOUND);
    stub.testInt(1);
    Map context = ((BindingProvider) stub).getResponseContext();
    Object testValue = context.get(USER_HANDLER_PROPERTY_NAME);
    assertNotNull("did not receive first handler property in response context", testValue);
    assertEquals("property value incorrect", USER_PROPERTY_HANDLER_SET, (String) testValue);
    // this is the last property added
    testValue = context.get(USER_HANDLER_PROPERTY_NAME + INBOUND);
    assertNotNull("did not receive second handler property in response context", testValue);
    assertEquals("property value incorrect", USER_PROPERTY_HANDLER_SET + INBOUND, (String) testValue);
}
Also used : HandlerTracker(fromwsdl.handler.common.HandlerTracker) BindingProvider(jakarta.xml.ws.BindingProvider) HashMap(java.util.HashMap) Map(java.util.Map)

Example 29 with BindingProvider

use of jakarta.xml.ws.BindingProvider 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 30 with BindingProvider

use of jakarta.xml.ws.BindingProvider 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

BindingProvider (jakarta.xml.ws.BindingProvider)75 Binding (jakarta.xml.ws.Binding)32 Handler (jakarta.xml.ws.handler.Handler)28 Service (jakarta.xml.ws.Service)17 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)17 QName (javax.xml.namespace.QName)16 URL (java.net.URL)9 ArrayList (java.util.ArrayList)8 Source (javax.xml.transform.Source)8 SOAPMessage (jakarta.xml.soap.SOAPMessage)7 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)7 List (java.util.List)6 Map (java.util.Map)6 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)5 JAXBElement (jakarta.xml.bind.JAXBElement)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 StreamSource (javax.xml.transform.stream.StreamSource)5 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)4 MimeHeaders (jakarta.xml.soap.MimeHeaders)4 WebServiceException (jakarta.xml.ws.WebServiceException)4