首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> Java 程式設計 >> Java 綜合教學

Apache CXF WebService 異常排查:No DestinationFactory for transport http 解決方案

     編輯:Java 綜合教學

Apache CXF WebService 異常排查:No DestinationFactory for transport http 解決方案

啟動 CXF 服務端時拋出異常堆疊:

Caused by: java.io.IOException: Could not find destination factory for transport https://schemas.xmlsoap.org/soap/http
    at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:133)
Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace https://cxf.apache.org/transports/http.
    at org.apache.cxf.bus.managers.DestinationFactoryManagerImpl.getDestinationFactory(DestinationFactoryManagerImpl.java:122)

根因分析

CXF 核心模組 未包含 HTTP 傳輸實現。CXF 採用模組化設計,HTTP 傳輸需額外引入 cxf-rt-transports-http 模組。

解決方案

在 pom.xml 添加依賴(版本與 CXF 核心一致,如 3.1.5):

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>3.1.5</version>
</dependency>

常見 CXF 核心依賴組合

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-core</artifactId>
    <version>3.1.5</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>3.1.5</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>3.1.5</version>
</dependency>
<!-- 如需 JSON/REST 支援 -->
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-rs-extension-providers</artifactId>
    <version>3.1.5</version>
</dependency>

驗證方式

  • 重新編譯啟動,服務端正常發布 WSDL
  • 客戶端成功調用無傳輸層異常
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved