Search in sources :

Example 21 with BindingProvider

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

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

the class EndToEndTest 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(handler.handler_processing.common.HandlerTracker) BindingProvider(jakarta.xml.ws.BindingProvider) Map(java.util.Map)

Example 23 with BindingProvider

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

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

Example 25 with BindingProvider

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

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