Search in sources :

Example 6 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 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;
// int diff = 4; // 2 per handler invoked
// 
// int y = stub.hello(x);
// assertEquals(x+diff, y); // x+4 with all handlers
// }
/*
     * 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) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 7 with BindingProvider

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

the class HandlerClient method testLogicalSource.

/*
     * Test removes the static handler and adds a logical
     * handler that uses a Source to change the message.
     */
public void testLogicalSource() throws Exception {
    Hello stub = createStub();
    Binding binding = ((BindingProvider) stub).getBinding();
    LogicalTestHandler handler = new LogicalTestHandler();
    handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE);
    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) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 8 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_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 9 with BindingProvider

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

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

the class ClientTest method test.

public void test() throws SOAPException, IOException {
    // -- TEST different SOAPACTION properties in RequestContext
    File file = new File("testcases/externalmetadata/fromjava/client/external-wsdl-customization-client.xml");
    WebServiceFeature feature = ExternalMetadataFeature.builder().addFiles(file).build();
    FAKENAME port = new EchoImplService().getFAKENAMEPort(feature);
    Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();
    // THIS next line is causing the SOAPACTION http header to go blank, if fix JAX_WS-1049 not applied ...
    requestContext.keySet();
    port.doSomething();
    // -- TEST dispatch: http://java.net/jira/browse/JAX_WS-1014 : Bug <12883765>
    String jaxwsMsg = "<?xml version='1.0' encoding='UTF-8'?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Body><doSomething xmlns=\"overriden-target-namespace\"/></S:Body></S:Envelope>";
    EchoImplService service = new EchoImplService();
    Dispatch<SOAPMessage> dispatch = service.createDispatch(new QName("overriden-target-namespace", "FAKE-NAMEPort"), SOAPMessage.class, Service.Mode.MESSAGE);
    Map<String, List> headersMap = new HashMap<String, List>();
    headersMap.put("X-ExampleHeader2", Collections.singletonList("Value"));
    Map<String, Object> context = dispatch.getRequestContext();
    context.put(MessageContext.HTTP_REQUEST_HEADERS, headersMap);
    context.put(SOAPACTION_USE_PROPERTY, Boolean.TRUE);
    MimeHeaders mhs = new MimeHeaders();
    mhs.addHeader("My-Content-Type", "text/xml");
    mhs.addHeader("SOAPAction", "overridenInputAction");
    SOAPMessage msg = MessageFactory.newInstance().createMessage(mhs, new ByteArrayInputStream(jaxwsMsg.getBytes()));
    dispatch.invoke(msg);
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) BindingProvider(jakarta.xml.ws.BindingProvider) SOAPMessage(jakarta.xml.soap.SOAPMessage) MimeHeaders(jakarta.xml.soap.MimeHeaders) ByteArrayInputStream(java.io.ByteArrayInputStream) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) List(java.util.List) File(java.io.File)

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