Search in sources :

Example 1 with JMSMessageHeadersType

use of org.apache.cxf.transport.jms.JMSMessageHeadersType in project cxf by apache.

the class GreeterImplQueueDecoupledOneWays method sendReply.

protected void sendReply() {
    JMSMessageHeadersType headers = (JMSMessageHeadersType) context.getMessageContext().get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
    if (headers == null || headers.getJMSReplyTo() == null) {
        synchronized (this) {
            if (!specCompliant) {
                asyncEx = new Exception("ReplyTo header in the server Request context was null");
            }
            notifyAll();
        }
        return;
    } else if (headers != null && headers.getJMSReplyTo() != null && specCompliant) {
        synchronized (this) {
            asyncEx = new Exception("ReplyTo header in the server Request context was not null");
            notifyAll();
        }
        return;
    }
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysReplyPort");
    Throwable e = null;
    try {
        URL wsdl = getClass().getResource("/wsdl/jms_test.wsdl");
        HelloWorldQueueDecoupledOneWaysService service = new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
        HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
        reply = "Re:" + request;
        greeter.greetMeOneWay(reply);
    } catch (Throwable t) {
        e = t;
    }
    synchronized (this) {
        asyncEx = e;
        notifyAll();
    }
}
Also used : HelloWorldOneWayPort(org.apache.cxf.hello_world_jms.HelloWorldOneWayPort) QName(javax.xml.namespace.QName) JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) URL(java.net.URL) HelloWorldQueueDecoupledOneWaysService(org.apache.cxf.hello_world_jms.HelloWorldQueueDecoupledOneWaysService)

Example 2 with JMSMessageHeadersType

use of org.apache.cxf.transport.jms.JMSMessageHeadersType 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 3 with JMSMessageHeadersType

use of org.apache.cxf.transport.jms.JMSMessageHeadersType 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 4 with JMSMessageHeadersType

use of org.apache.cxf.transport.jms.JMSMessageHeadersType in project cxf by apache.

the class TwoWayJMSImplBase method addToReply.

private void addToReply(String key, String value) {
    MessageContext mc = wsContext.getMessageContext();
    JMSMessageHeadersType responseHeaders = (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS);
    responseHeaders.putProperty(key, value);
}
Also used : JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) MessageContext(javax.xml.ws.handler.MessageContext)

Example 5 with JMSMessageHeadersType

use of org.apache.cxf.transport.jms.JMSMessageHeadersType in project cxf by apache.

the class SOAPJMSTestSuiteTest method oneWayTest.

private void oneWayTest(TestCaseType testcase, JMSSimplePortType port) throws Exception {
    closeable = (java.io.Closeable) port;
    InvocationHandler handler = Proxy.getInvocationHandler(port);
    BindingProvider bp = (BindingProvider) handler;
    Map<String, Object> requestContext = bp.getRequestContext();
    JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
    requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
    Exception e = null;
    try {
        port.ping("test");
    } catch (Exception e1) {
        e = e1;
    }
    checkJMSProperties(testcase, requestHeader);
    if (e != null) {
        throw e;
    }
}
Also used : JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) BindingProvider(javax.xml.ws.BindingProvider) InvocationHandler(java.lang.reflect.InvocationHandler) JMSException(javax.jms.JMSException) WebServiceException(javax.xml.ws.WebServiceException)

Aggregations

JMSMessageHeadersType (org.apache.cxf.transport.jms.JMSMessageHeadersType)20 Test (org.junit.Test)13 JMSSimplePortType (org.apache.cxf.jms_simple.JMSSimplePortType)8 TestCaseType (org.apache.cxf.testsuite.testcase.TestCaseType)8 JMSException (javax.jms.JMSException)7 BindingProvider (javax.xml.ws.BindingProvider)7 WebServiceException (javax.xml.ws.WebServiceException)7 URL (java.net.URL)6 QName (javax.xml.namespace.QName)6 Closeable (java.io.Closeable)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 HelloWorldOneWayPort (org.apache.cxf.hello_world_jms.HelloWorldOneWayPort)3 HelloWorldQueueDecoupledOneWaysService (org.apache.cxf.hello_world_jms.HelloWorldQueueDecoupledOneWaysService)3 InvocationHandler (java.lang.reflect.InvocationHandler)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 ExecutionException (java.util.concurrent.ExecutionException)2 Endpoint (javax.xml.ws.Endpoint)2 MessageContext (javax.xml.ws.handler.MessageContext)2 JMSGreeterPortType (org.apache.cxf.jms_greeter.JMSGreeterPortType)2 JMSGreeterService (org.apache.cxf.jms_greeter.JMSGreeterService)2