Search in sources :

Example 41 with BindingProvider

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

the class EndToEndErrorTester method testServiceSpecificException1.

/*
     * Have the endpoint throw a service specific exception and make
     * sure that the client gets it back. Test case for bug 6232002.
     */
public void testServiceSpecificException1() throws Exception {
    TestService_Service service = getService();
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    // get stubs and clear the trackers
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    reportStub.clearHandlerTracker();
    tracker.clearAll();
    try {
        testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
        fail("did not receive exception (1)");
    } catch (MyFaultException mfe) {
    // passed
    } catch (Exception e) {
        fail("did not receive MyFaultException (1), received " + e);
    }
    // check closed handlers to be sure
    List<String> actualClosed = tracker.getClosedHandlers();
    int[] closed = { 7, 5, 4, 3, 1, 0 };
    assertEquals("Did not get proper number of closed handlers", closed.length, actualClosed.size());
    for (int i = 0; i < closed.length; i++) {
        assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], actualClosed.get(i));
    }
    // remove all client handlers and try again
    Binding binding = ((BindingProvider) testStub).getBinding();
    binding.setHandlerChain(new ArrayList<Handler>());
    tracker.clearAll();
    try {
        testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
        fail("did not receive exception (2)");
    } catch (MyFaultException mfe) {
    // passed
    } catch (Exception e) {
        fail("did not receive MyFaultException (2), received " + e);
    }
    // this just makes sure there really were no handlers
    actualClosed = tracker.getClosedHandlers();
    assertTrue("should not have been closed handlers", actualClosed.isEmpty());
}
Also used : Binding(jakarta.xml.ws.Binding) HandlerTracker(fromwsdl.handler.common.HandlerTracker) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider) WebServiceException(jakarta.xml.ws.WebServiceException) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 42 with BindingProvider

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

the class MtomApp method main.

public static void main(String[] args) throws Exception {
    Hello port = new HelloService().getHelloPort(new MTOMFeature());
    Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
    ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
    testUpload(port);
}
Also used : MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 43 with BindingProvider

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

the class ClientFeatureTest method validateFeatureList.

private void validateFeatureList(Object bindingProvider, String expectedEncoding) throws Exception {
    Binding binding = ((BindingProvider) bindingProvider).getBinding();
    WSFeatureList list = (((WSBinding) binding).getFeatures());
    // System.out.println(list);
    SerializationFeature encoding = list.get(SerializationFeature.class);
    if (expectedEncoding == null) {
        assertNull("There should not be a SerializationFeature", encoding);
    } else {
        assertEquals("Mismatched encoding in SerializationFeature", expectedEncoding, encoding.getEncoding());
    }
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) Binding(jakarta.xml.ws.Binding) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) WSFeatureList(com.sun.xml.ws.api.WSFeatureList) BindingProvider(jakarta.xml.ws.BindingProvider) SerializationFeature(com.sun.xml.ws.developer.SerializationFeature)

Example 44 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) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 45 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) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) 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