日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java cxf 双向通讯_CXF 在spring boot 2 发布多个服务

發布時間:2023/12/9 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java cxf 双向通讯_CXF 在spring boot 2 发布多个服务 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

0. 問題來源

之前配置cxf服務端都是在spring 3以下,后來使用spring mvc 還都是基于xml的配置文件模式,在springboot模式下,實現起來更為簡單了。此次記錄下spring boot 2下的實現方式。

1. 準備工作

項目中,直接拉入spring boot cxf相關依賴

org.apache.cxf

cxf-spring-boot-starter-jaxws

3.2.4

系統環境中安裝解壓版的cxf代碼(用于服務端生成代碼)

我這里使用的版本是 apache-cxf-3.2.7,不再贅述,解壓,配置環境變量

2. 具體細節

生成客戶端代碼,然后一股腦懟到項目里

wsdl2java -encoding utf-8 -d 你的目錄 -client

創建CxfConfig.java 在項目中

package com.account.ibm.sync.config;

import org.apache.cxf.bus.spring.SpringBus;

import org.apache.cxf.jaxws.EndpointImpl;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.annotation.Qualifier;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

import com.cmcc.mss.sb_eas_eas_importclaimchannelserviceinfosrv.SBEASEASImportClaimChannelServiceInfoSrv;

import com.cmcc.soa.osb_bp_soa_hq_importtransmissinotifysrv.OSBBPSOAHQImportTransmissiNotifySrv;

/**

* @description cxf配置 用于發布服務所用的類

* @author fg

* @date 2019年1月29日

*/

@Configuration

public class CxfConfig {

@Autowired

private SpringBus bus;

@Bean

@Qualifier("oSBBPSOAHQImportTransmissiNotifySrv")

public Endpoint importTransmissiNotifySrv(OSBBPSOAHQImportTransmissiNotifySrv oSBBPSOAHQImportTransmissiNotifySrv) {

EndpointImpl endpoint = new EndpointImpl(bus, oSBBPSOAHQImportTransmissiNotifySrv);

endpoint.publish("/OSB_BP_SOA_HQ_ImportTransmissiNotifySrv");

return endpoint;

}

@Bean

@Qualifier("sBEASEASImportClaimChannelServiceInfoSrv")

public Endpoint importClaimChannelServiceInfoSrv(SBEASEASImportClaimChannelServiceInfoSrv sBEASEASImportClaimChannelServiceInfoSrv) {

EndpointImpl endpoint = new EndpointImpl(bus, sBEASEASImportClaimChannelServiceInfoSrv);

endpoint.publish("/SB_EAS_EAS_ImportClaimChannelServiceInfoSrv");

return endpoint;

}

@Bean(name = Bus.DEFAULT_BUS_ID)

public SpringBus springBus() {

SpringBus springBus = new SpringBus();

LoggingFeature logFeature = new LoggingFeature();

logFeature.setPrettyLogging(true);

logFeature.initialize(springBus);

springBus.getFeatures().add(logFeature);

return springBus;

}

}

我這里是兩個服務,因此是聲明兩個@Bean Endpoint,而不是網上一些說法配置兩個CxfConfig

2. 測試

訪問如下地址,可以看到兩個接口

http://localhost/你的項目名/services/

總結

以上是生活随笔為你收集整理的java cxf 双向通讯_CXF 在spring boot 2 发布多个服务的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。