下午测试了一下Spring2.x与XFire1.2.6的集成。一启动就报错。最开始提示org.jdom.document的错误,原来只是缺少jdom的jar包,可能是这种集成需要jdom的支持。而他们之间的集成最大的问题在于XFire1.2.6集成的Spring1.x系列的。在Spring2.x中是没有org.springframework.web.servlet.x系列的jar包的。所以在集成的时候,会提示找不到这个系列下的类,要解决该问题,则需要在导入一个spring-webmvc.jar包。这样就没有问题了。附带集成的部分代码:
web.xml
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext.xml classpath:xfire-servlet.xml </param-value> </context-param> <servlet> <servlet-name>xfire</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>xfire</servlet-name> <url-pattern>*.ws</url-pattern> </servlet-mapping> <servlet> <servlet-name>services</servlet-name> <servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>services</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
xfire-servlet.xml配置文件:
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <import resource="classpath:org/codehaus/xfire/spring/xfire.xml"/> <!-- 引入XFire导出器 --> <bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" abstract="true" lazy-init="true"> <property name="serviceFactory" ref="xfire.serviceFactory"></property> <property name="xfire" ref="xfire"></property> </bean> <bean id="ws" class="com.unit.service.impl.WServiceImpl"></bean> <!-- 配置接口 --> <bean id="Hello" parent="baseWebService"> <property name="serviceBean" ref="ws"></property> <property name="serviceClass" value="com.unit.service.WService"></property> </bean> <!-- 定义访问的URL --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="urlMap"> <map> <entry key="/Hello.ws"> <ref bean="Hello"/> </entry> </map> </property> </bean> </beans>