use of org.apache.cxf.jms_greeter.JMSGreeterPortType 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);
}
use of org.apache.cxf.jms_greeter.JMSGreeterPortType 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);
}
}
use of org.apache.cxf.jms_greeter.JMSGreeterPortType 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());
}
use of org.apache.cxf.jms_greeter.JMSGreeterPortType in project cxf by apache.
the class SoapJmsSpecTest method testGzip.
@Test
public void testGzip() throws Exception {
URL wsdl = getWSDLURL(WSDL);
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setBus(bus);
factory.setServiceClass(JMSGreeterPortType.class);
factory.setWsdlURL(wsdl.toExternalForm());
factory.getFeatures().add(cff);
factory.getFeatures().add(new GZIPFeature());
factory.setAddress("jms:queue:test.cxf.jmstransport.queue6");
JMSGreeterPortType greeter = (JMSGreeterPortType) markForClose(factory.create());
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("Bonjour", reply);
}
}
use of org.apache.cxf.jms_greeter.JMSGreeterPortType 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());
}
}
Aggregations