Search in sources :

Example 41 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class JMSClientServerTest method testQueueDecoupledOneWaysConnection.

@Test
public void testQueueDecoupledOneWaysConnection() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    String wsdl2 = "testutils/jms_test.wsdl".intern();
    wsdlStrings.add(wsdl2);
    broker.updateWsdl(getBus(), wsdl2);
    HelloWorldQueueDecoupledOneWaysService service = new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
    Endpoint requestEndpoint = null;
    Endpoint replyEndpoint = null;
    HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
    try {
        GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays();
        requestEndpoint = Endpoint.publish(null, requestServant, new LoggingFeature());
        GreeterImplQueueDecoupledOneWaysDeferredReply replyServant = new GreeterImplQueueDecoupledOneWaysDeferredReply();
        replyEndpoint = Endpoint.publish(null, replyServant, new LoggingFeature());
        BindingProvider bp = (BindingProvider) greeter;
        Map<String, Object> requestContext = bp.getRequestContext();
        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
        requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
        requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
        String expectedRequest = "JMS:Queue:Request";
        greeter.greetMeOneWay(expectedRequest);
        String request = requestServant.ackRequestReceived(5000);
        if (request == null) {
            if (requestServant.getException() != null) {
                fail(requestServant.getException().getMessage());
            } else {
                fail("The oneway call didn't reach its intended endpoint");
            }
        }
        assertEquals(expectedRequest, request);
        requestServant.proceedWithReply();
        String expectedReply = requestServant.ackReplySent(5000);
        if (expectedReply == null) {
            if (requestServant.getException() != null) {
                fail(requestServant.getException().getMessage());
            } else {
                fail("The decoupled one-way reply was not sent");
            }
        }
        String reply = replyServant.ackRequest(5000);
        if (reply == null) {
            if (replyServant.getException() != null) {
                fail(replyServant.getException().getMessage());
            } else {
                fail("The decoupled one-way reply didn't reach its intended endpoint");
            }
        }
        assertEquals(expectedReply, reply);
    } catch (Exception ex) {
        throw ex;
    } finally {
        if (requestEndpoint != null) {
            requestEndpoint.stop();
        }
        if (replyEndpoint != null) {
            replyEndpoint.stop();
        }
        ((java.io.Closeable) greeter).close();
    }
}
Also used : HelloWorldOneWayPort(org.apache.cxf.hello_world_jms.HelloWorldOneWayPort) QName(javax.xml.namespace.QName) Closeable(java.io.Closeable) JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) ExecutionException(java.util.concurrent.ExecutionException) Endpoint(javax.xml.ws.Endpoint) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) HelloWorldQueueDecoupledOneWaysService(org.apache.cxf.hello_world_jms.HelloWorldQueueDecoupledOneWaysService) Test(org.junit.Test)

Example 42 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class JMSClientServerTest method testQueueOneWaySpecCompliantConnection.

@Test
public void testQueueOneWaySpecCompliantConnection() throws Throwable {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    assertNotNull(wsdl);
    String wsdlString2 = "testutils/jms_test.wsdl";
    wsdlStrings.add(wsdlString2);
    broker.updateWsdl(getBus(), wsdlString2);
    HelloWorldQueueDecoupledOneWaysService service = new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
    assertNotNull(service);
    Endpoint requestEndpoint = null;
    HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
    try {
        GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays(true);
        requestEndpoint = Endpoint.publish(null, requestServant);
        BindingProvider bp = (BindingProvider) greeter;
        Map<String, Object> requestContext = bp.getRequestContext();
        JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
        requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
        requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
        String expectedRequest = "JMS:Queue:Request";
        greeter.greetMeOneWay(expectedRequest);
        String request = requestServant.ackRequestReceived(5000);
        if (request == null) {
            if (requestServant.getException() != null) {
                fail(requestServant.getException().getMessage());
            } else {
                fail("The oneway call didn't reach its intended endpoint");
            }
        }
        assertEquals(expectedRequest, request);
        requestServant.proceedWithReply();
        boolean ack = requestServant.ackNoReplySent(5000);
        if (!ack) {
            if (requestServant.getException() != null) {
                Throwable ex = requestServant.getException();
                if (ex.getMessage().contains("Request context was not null")) {
                    return;
                }
                throw requestServant.getException();
            }
            fail("The decoupled one-way reply was sent");
        }
    } catch (Exception ex) {
        throw ex;
    } finally {
        if (requestEndpoint != null) {
            requestEndpoint.stop();
        }
        ((java.io.Closeable) greeter).close();
    }
}
Also used : HelloWorldOneWayPort(org.apache.cxf.hello_world_jms.HelloWorldOneWayPort) QName(javax.xml.namespace.QName) Closeable(java.io.Closeable) JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) ExecutionException(java.util.concurrent.ExecutionException) Endpoint(javax.xml.ws.Endpoint) HelloWorldQueueDecoupledOneWaysService(org.apache.cxf.hello_world_jms.HelloWorldQueueDecoupledOneWaysService) Test(org.junit.Test)

Example 43 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class ClientServerSessionTest method doSessionsTest.

private void doSessionsTest(String url) {
    GreeterService service = new GreeterService();
    assertNotNull(service);
    Greeter greeter = service.getGreeterPort();
    Greeter greeter2 = service.getGreeterPort();
    BindingProvider bp = (BindingProvider) greeter;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
    bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    bp = (BindingProvider) greeter2;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
    bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    String result = greeter.greetMe("World");
    assertEquals("Hello World", result);
    assertEquals("Bonjour World", greeter.sayHi());
    result = greeter2.greetMe("Universe");
    assertEquals("Hello Universe", result);
    assertEquals("Bonjour Universe", greeter2.sayHi());
    // make sure session 1 was maintained
    assertEquals("Bonjour World", greeter.sayHi());
}
Also used : Greeter(org.apache.cxf.greeter_control.Greeter) GreeterService(org.apache.cxf.greeter_control.GreeterService) BindingProvider(javax.xml.ws.BindingProvider)

Example 44 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class ClientServerSessionTest method testInvocationWithPerRequestAnnotation.

@Test
public void testInvocationWithPerRequestAnnotation() throws Exception {
    GreeterService service = new GreeterService();
    assertNotNull(service);
    Greeter greeter = service.getGreeterPort();
    BindingProvider bp = (BindingProvider) greeter;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/PerRequest");
    bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    String result = greeter.greetMe("World");
    assertEquals("Hello World", result);
    assertEquals("Bonjour default", greeter.sayHi());
}
Also used : Greeter(org.apache.cxf.greeter_control.Greeter) GreeterService(org.apache.cxf.greeter_control.GreeterService) BindingProvider(javax.xml.ws.BindingProvider) Test(org.junit.Test)

Example 45 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class ClientServerSessionTest method testInvocationWithSpringBeanAnnotation.

@Test
public void testInvocationWithSpringBeanAnnotation() throws Exception {
    GreeterService service = new GreeterService();
    assertNotNull(service);
    Greeter greeter = service.getGreeterPort();
    BindingProvider bp = (BindingProvider) greeter;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/SpringBean");
    bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    String result = greeter.greetMe("World");
    assertEquals("Hello World", result);
    assertEquals("Bonjour World", greeter.sayHi());
}
Also used : Greeter(org.apache.cxf.greeter_control.Greeter) GreeterService(org.apache.cxf.greeter_control.GreeterService) BindingProvider(javax.xml.ws.BindingProvider) Test(org.junit.Test)

Aggregations

BindingProvider (javax.xml.ws.BindingProvider)147 URL (java.net.URL)87 Test (org.junit.Test)74 Service (javax.xml.ws.Service)65 QName (javax.xml.namespace.QName)41 WebServiceException (javax.xml.ws.WebServiceException)24 Greeter (org.apache.hello_world_soap_http.Greeter)23 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)18 Bus (org.apache.cxf.Bus)17 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)15 InvocationHandler (java.lang.reflect.InvocationHandler)14 SOAPService (org.apache.hello_world_soap_http.SOAPService)14 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)12 STSClient (org.apache.cxf.ws.security.trust.STSClient)11 Greeter (org.apache.cxf.greeter_control.Greeter)10 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 SOAPBinding (javax.xml.ws.soap.SOAPBinding)9 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)9 Client (org.apache.cxf.endpoint.Client)9 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)8