Java Reference
In-Depth Information
<servlet-mapping>
<servlet-name>weather</servlet-name>
<url-pattern> /services/*</url-pattern>
</servlet-mapping>
</web-app>
In the Spring MVC configuration file, weather-servlet.xml , you declare a bean for the weather
service implementation and export it as a web service by using XFireExporter .
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd " >
<bean id="weatherService"
class="com.apress.springenterpriserecipes.weather.WeatherServiceImpl" />
<bean name="/WeatherService"
class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="xfire" ref="xfire" />
<property name="serviceBean" ref="weatherService" />
<property name="serviceInterface"
value="com.apress.springenterpriserecipes.weather.WeatherService" />
</bean>
</beans>
For an XFireExporter instance, you have to configure a service object to export and its service
interface. Note that this exporter requires a reference to the core xfire bean for actual web
service processing. The xfire bean is defined in the bean configuration file bundled with the XFire
library. You only have to configure ContextLoaderListener in your web.xml to load this file from the
classpath.
<web-app ...>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:org/codehaus/xfire/spring/xfire.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
...
</web-app>
Now you can deploy your web application to a web container such as Apache Tomcat 6.0. Then you
can access this web service with the following URL:
http://localhost:8080/weather/services/WeatherService
Search WWH ::




Custom Search