2.1.3版cxf配置webservice備忘

來源:互聯網
上載者:User

標籤: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備忘

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.