1. 程式人生 > >Spring整合XFire開發WebService問題

Spring整合XFire開發WebService問題

最近在網上發現有spring整合XFire開發WebService

MyEclipse新建webservice工程在Servlet class選擇org.codehaus.xfire.spring.XFireSpringServlet

配置如下:


}

 

程式碼考過來啟動服務發現出現如下問題

嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".

提示找不到beans標籤。

找了以下資料發現是

<beans>標籤問題,把<beans標籤的schema去掉,加上<DOCTYPE>

修改spring配置檔案如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="helloWS" class="org.ccsoft.HelloWSImp" />
 <bean name="helloService"
  class="org.codehaus.xfire.spring.ServiceBean">
  <property name="serviceBean" ref="helloWS" />
  <property name="serviceClass" value="org.ccsoft.HelloWS" />
  <property name="inHandlers">
   <list>
    <ref bean="addressingHandler" />
   </list>
  </property>
 </bean>
 <bean id="addressingHandler"
  class="org.codehaus.xfire.addressing.AddressingInHandler" />
</beans>

再次啟動服務ok;