標籤:1.3 org 需要 路徑 wss java cxf instance poi
以前用cxf配置webservice一直都很順利,結合spring進行管理和注入都非常方便。近來公司需要在老架構上加入webservice,ssh的架構還是十年前的東西,新一點的cxf版本根本無法配置啟動。無奈版本一直降低到了2.1.3才能正常使用。就是這麼個低版本的配置讓人栽了個大跟頭。
配置這塊其實很簡單。
web.xml裡要載入cxf的配置
同樣是web.xml裡,要配置servlet,以及監聽的路徑。
看看cxf的設定檔,真正的坑在這裡。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<!-- webservice 介面服務定義 -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<!-- 3.X寫法 -->
<jaxws:endpoint address="/demoService" publish="true" implementor="com.demo.ws.DemoWebServiceImpl" />
<!-- 2.X寫法 -->
<jaxws:endpoint id="reportDataService" address="/reportDataService"
implementorClass="com.demo.ws.IReportDataWsService">
<jaxws:implementor>
<bean id="reportDataServiceImpl" class="com.demo.ws.ReportDataWsServiceImpl">
</bean>
</jaxws:implementor>
</jaxws:endpoint>
</beans>
2.1.3版本裡你要用3.X的寫法,也能對外發布webservice,啟動以及調用一點都不報錯,但注入就完蛋了。始終是得到的null。換寫法了就妥妥的。
為了保持文章完整性,說明下java類的配置。
以此幾年我慘被謀殺的半個下午。
2.1.3版cxf配置webservice備忘