(1)建立接口与实现类
(2)引入XFire的jar包.
commons-logging-1.0.4.jar
jdom-1.0.jar
spring-1.2.6.jar
wsdl4j-1.6.1.jar
xbean-spring-2.8.jar
xfire-all-1.2.6.jar
xfire-core-1.2.6.jar
(3)在service.xml中配置服务.
<beans xmlns="http://xfire.codehaus.org/config/1.0"> <service> <name>服务名</name> <namespace>命名空间</namespace> <serviceClass>接口全路径 </serviceClass> <implementationClass> 实现类全路径 </implementationClass> </service> </beans>
(4)web.xml中配置XFire的Servlet及其配置
<servlet> <servlet-name>XFireServlet</servlet-name> <servlet-class> org.codehaus.xfire.transport.http.XFireConfigurableServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>XFireServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>XFireServlet</servlet-name> <url-pattern>/servlet/XFireServlet/*</url-pattern> </servlet-mapping>
(5)访问测试这个服务发布是否成功: http://localhost:8080/项目名/services/服务名称?wsdl
注意wsdl最后的地址: <wsdlsoap:address location="http://localhost:8080/WebServiceTest1/services/helloworld"/>