Java First SOAP\JMS Service With CXF
mtarullo463 Jul 15, 2011 10:25 AMI am working on an R&D service that will be using SOAP over JMS. The following are the interface for the service and and the implementation:
package gov.faa.swim.nsrr.soapoverjms;
public interface ISoapJmsWeather
{
public String GetForecast(String locationCityName);
public float GetTemperature(int locationCityZipCode);
public void SetTemperature(int locationCityZipCode, float locationTemperature);
}
package gov.faa.swim.nsrr.soapoverjms;
public class SoapJmsWeatherImpl implements ISoapJmsWeather
{
private String cityForecasts[][] = {{"New York", "Philadelphia", "Baltimore"},
{"10036", "19107", "21225" },
{"Cloudy", "Sunny", "Rain" },
{"75.0", "90.5", "80.0" }};
public String GetForecast(String locationCityName)
{
.....
}
public float GetTemperature(int locationCityZipCode)
{
.....
}
public void SetTemperature(int locationCityZipCode, float locationTemperature)
{
.....
}
}
The Fuse Services Framework Developing Applications Using JAX-WS
Version 2.4 June 2011 - Section 17 Using SOAP over JMS provides the following code for "publishing" the service (modified slightly for my interface and implementation):
package gov.faa.swim.nsrr.soapoverjms;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
public class SoapJmsWeatherPublisherForCXF
{
public void Publish()
{
String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3" +
"?jndiInitialContextFactory" +
"=org.apache.activemq.jndi.ActiveMQInitialContextFactory" +
"&jndiConnectionFactoryName=ConnectionFactory" +
"&jndiURL=tcp://localhost:61500";
SoapJmsWeatherImpl implementor = new SoapJmsWeatherImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(ISoapJmsWeather.class);
svrFactory.setAddress(address);
svrFactory.setTransportId
(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
svrFactory.setServiceBean(implementor);
svrFactory.create();
}
}
My questions are:
1) Where does this belong (as you can see I created a class for it)?
2) How does it get called?
I am using JBoss 6.0 AS for this R&D project which now comes with the CXF Web Services Stack. We have also replaced the JBoss messaging with ActiveMQ and will be using this for JMS.
Thank you.