Java Reference
In-Depth Information
Solution
Spring comes with several service exporters that can export a bean as a remote service based on the
RMI, Hessian, Burlap, or HTTP Invoker remoting technologies, but Spring doesn't come with a service
exporter that can export a bean as a web service. However, there's an external framework called
XFire
(
http://xfire.codehaus.org/
) th
at supplies one. XFire is an open source Java SOAP framework that can
export a simple Java object as a web service. XFire supports Spring by providing facilities such as a
service exporter and a client proxy factory bean, whose usage is consistent with those provided by Spring
for other remoting technologies.
How It Works
Exposing a Web Service Using XFire
To expose a web service using XFire in Spring, you first create the following directory structure for your
web application context.
■
Note To expose a web service using XFire, you have to download and install XFire (e.g., v1.2.6). Then copy
xfire-all-1.2.6.jar
(located in the root of the XFire installation),
activation-1.1.jar
,
jdom-1.0.jar
,
stax-api-1.0.1.jar
,
wsdl4j-1.6.1.jar
, and
wstx-asl-3.2.0.jar
(all located in the
lib
directory) to the
WEB-INF/lib
directory.
weather/
WEB-INF/
classes/
lib/*jar
weather-servlet.xml
web.xml
In
web.xml
, you configure Spring MVC's
DispatcherServlet
and map all the URLs under the
services
path to it.
<web-app version="2.4" xmlns="
http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
<servlet>
<servlet-name>weather</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Search WWH ::
Custom Search