THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
// You just need to set the address with JMS URI
String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3"
+ "?jndiInitialContextFactory"
+ "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ "&jndiConnectionFactoryName=ConnectionFactory&jndiURL=tcp://localhost:61500";
Hello implementor = new HelloImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(Hello.class);
svrFactory.setAddress(address);
// And specify the transport ID with SOAP over JMS specification
svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
svrFactory.setServiceBean(implementor);
svrFactory.create();
// Alternatively using JAXWS Endpoint.create and avoiding JNDI
ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61500");
EndpointImpl ep = (EndpointImpl)Endpoint.create(impl);
ep.setBus(bus);
ep.getFeatures().add(new ConnectionFactoryFeature(cf));
ep.publish("jms:queue:test.cxf.jmstransport.queue?timeToLive=1000"); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
public void invoke() throws Exception { // You just need to set the address with JMS URI String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&jndiConnectionFactoryName=ConnectionFactory" + "&jndiURL=tcp://localhost:61500"; JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); // And specify the transport ID with SOAP over JMS specification factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID); factory.setServiceClass(Hello.class); factory.setAddress(address); Hello client = (Hello)factory.create(); String reply = client.sayHi(" HI"); System.out.println(reply); } // Alternatively using the JAXWS API with jms details defined in WSDL while avoiding JNDI SOAPService2 service = new SOAPService2(wsdl, serviceName); // Using the generated service ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61500"); ConnectionFactoryFeature cff = new ConnectionFactoryFeature(cf); Greeter greeter = markForClose(service.getPort(portName, Greeter.class, cff)); // Connection Factory can be set as a feature in CXF >= 3.0.0 |
...