Search in sources :

Example 1 with JMSGreeterService

use of org.apache.cxf.jms_greeter.JMSGreeterService in project cxf by apache.

the class Client method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("please specify wsdl");
        System.exit(1);
    }
    File wsdl = new File(args[0]);
    JMSGreeterService service = new JMSGreeterService(wsdl.toURI().toURL(), SERVICE_NAME);
    JMSGreeterPortType greeter = (JMSGreeterPortType) service.getPort(PORT_NAME, JMSGreeterPortType.class);
    System.out.println("Invoking sayHi...");
    System.out.println("server responded with: " + greeter.sayHi());
    System.out.println();
    System.out.println("Invoking greetMe...");
    System.out.println("server responded with: " + greeter.greetMe(System.getProperty("user.name")));
    System.out.println();
    System.out.println("Invoking greetMeOneWay...");
    greeter.greetMeOneWay(System.getProperty("user.name"));
    System.out.println("No response from server as method is OneWay");
    System.out.println();
    if (greeter instanceof Closeable) {
        ((Closeable) greeter).close();
    }
    System.exit(0);
}
Also used : Closeable(java.io.Closeable) JMSGreeterService(org.apache.cxf.jms_greeter.JMSGreeterService) JMSGreeterPortType(org.apache.cxf.jms_greeter.JMSGreeterPortType) File(java.io.File)

Example 2 with JMSGreeterService

use of org.apache.cxf.jms_greeter.JMSGreeterService in project cxf by apache.

the class SoapJmsSpecTest method testSpecJMS.

@Test
public void testSpecJMS() throws Exception {
    QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
    QName portName = new QName(SERVICE_NS, "GreeterPort");
    URL wsdl = getWSDLURL(WSDL);
    JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
    JMSGreeterPortType greeter = markForClose(service.getPort(portName, JMSGreeterPortType.class, cff));
    for (int idx = 0; idx < 5; idx++) {
        greeter.greetMeOneWay("test String");
        String greeting = greeter.greetMe("Milestone-" + idx);
        Assert.assertEquals("Hello Milestone-" + idx, greeting);
        String reply = greeter.sayHi();
        Assert.assertEquals(new String("Bonjour"), reply);
    }
}
Also used : QName(javax.xml.namespace.QName) JMSGreeterService(org.apache.cxf.jms_greeter.JMSGreeterService) JMSGreeterPortType(org.apache.cxf.jms_greeter.JMSGreeterPortType) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Example 3 with JMSGreeterService

use of org.apache.cxf.jms_greeter.JMSGreeterService in project cxf by apache.

the class SoapJmsSpecTest method testWsdlExtensionSpecJMS.

@Test
public void testWsdlExtensionSpecJMS() throws Exception {
    QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
    QName portName = new QName(SERVICE_NS, "GreeterPort");
    URL wsdl = getWSDLURL(WSDL);
    JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
    JMSGreeterPortType greeter = markForClose(service.getPort(portName, JMSGreeterPortType.class, cff));
    Map<String, Object> requestContext = ((BindingProvider) greeter).getRequestContext();
    JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
    requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
    String reply = greeter.sayHi();
    Assert.assertEquals("Bonjour", reply);
    requestContext = ((BindingProvider) greeter).getRequestContext();
    requestHeader = (JMSMessageHeadersType) requestContext.get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
    Assert.assertEquals("1.0", requestHeader.getSOAPJMSBindingVersion());
    Assert.assertEquals("\"test\"", requestHeader.getSOAPJMSSOAPAction());
    Assert.assertEquals(3000, requestHeader.getTimeToLive());
    Assert.assertEquals(DeliveryMode.PERSISTENT, requestHeader.getJMSDeliveryMode());
    Assert.assertEquals(7, requestHeader.getJMSPriority());
    Map<String, Object> responseContext = ((BindingProvider) greeter).getResponseContext();
    JMSMessageHeadersType responseHeader = (JMSMessageHeadersType) responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
    Assert.assertEquals("1.0", responseHeader.getSOAPJMSBindingVersion());
    Assert.assertEquals("\"test\"", responseHeader.getSOAPJMSSOAPAction());
    Assert.assertEquals(DeliveryMode.PERSISTENT, responseHeader.getJMSDeliveryMode());
    Assert.assertEquals(7, responseHeader.getJMSPriority());
}
Also used : QName(javax.xml.namespace.QName) JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) BindingProvider(javax.xml.ws.BindingProvider) JMSGreeterService(org.apache.cxf.jms_greeter.JMSGreeterService) JMSGreeterPortType(org.apache.cxf.jms_greeter.JMSGreeterPortType) URL(java.net.URL) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Example 4 with JMSGreeterService

use of org.apache.cxf.jms_greeter.JMSGreeterService in project cxf by apache.

the class SoapJmsSpecTest method testBindingVersionError.

@Test
public void testBindingVersionError() throws Exception {
    QName serviceName = new QName(SERVICE_NS, "JMSGreeterService");
    QName portName = new QName(SERVICE_NS, "GreeterPort");
    URL wsdl = getWSDLURL(WSDL);
    JMSGreeterService service = new JMSGreeterService(wsdl, serviceName);
    JMSGreeterPortType greeter = markForClose(service.getPort(portName, JMSGreeterPortType.class, cff));
    BindingProvider bp = (BindingProvider) greeter;
    Map<String, Object> requestContext = bp.getRequestContext();
    JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
    requestHeader.setSOAPJMSBindingVersion("0.3");
    requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
    try {
        greeter.greetMe("Milestone-");
        Assert.fail("Should have thrown a fault");
    } catch (SOAPFaultException ex) {
        Assert.assertTrue(ex.getMessage().contains("0.3"));
        Map<String, Object> responseContext = bp.getResponseContext();
        JMSMessageHeadersType responseHdr = (JMSMessageHeadersType) responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
        if (responseHdr == null) {
            Assert.fail("response Header should not be null");
        }
        Assert.assertTrue(responseHdr.isSOAPJMSIsFault());
    }
}
Also used : QName(javax.xml.namespace.QName) JMSMessageHeadersType(org.apache.cxf.transport.jms.JMSMessageHeadersType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) BindingProvider(javax.xml.ws.BindingProvider) JMSGreeterService(org.apache.cxf.jms_greeter.JMSGreeterService) JMSGreeterPortType(org.apache.cxf.jms_greeter.JMSGreeterPortType) Map(java.util.Map) URL(java.net.URL) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Aggregations

JMSGreeterPortType (org.apache.cxf.jms_greeter.JMSGreeterPortType)4 JMSGreeterService (org.apache.cxf.jms_greeter.JMSGreeterService)4 URL (java.net.URL)3 QName (javax.xml.namespace.QName)3 AbstractVmJMSTest (org.apache.cxf.systest.jms.AbstractVmJMSTest)3 Test (org.junit.Test)3 BindingProvider (javax.xml.ws.BindingProvider)2 JMSMessageHeadersType (org.apache.cxf.transport.jms.JMSMessageHeadersType)2 Closeable (java.io.Closeable)1 File (java.io.File)1 Map (java.util.Map)1 Endpoint (javax.xml.ws.Endpoint)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1