Springboot 集成 CXF 发布 Web service

news/2024/10/23 5:42:27/

导入需要使用的jar包

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-frontend-jaxws</artifactId><version>3.1.6</version>
</dependency>
<dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-transports-http</artifactId><version>3.1.6</version>
</dependency>

主要就是三个类,定义接口,接口实现,和接口配置。

定义接口

@WebService(name = "ServerService", // 暴露服务名称targetNamespace = "http://webservice.bloodapi.zlhospital.com"// 命名空间,一般是接口的包名倒序
)
public interface ServerService {@WebMethodpublic String writeBackStatus(@WebParam(name = "data") String data);
}

接口实现

@Service
@WebService(serviceName = "ServerService", // 与接口中指定的name一致targetNamespace = "http://webservice.bloodapi.zlhospital.com", // 与接口中的命名空间一致,一般是接口的包名倒endpointInterface = "com.zlhospital.bloodapi.webservice.ServerService"// 接口地址
)
public class ServerServiceImpl implements ServerService {Logger logger = LoggerFactory.getLogger(ServerServiceImpl.class);@Overridepublic String writeBackStatus(String data) {logger.info("传入的参数:{}", data);return data;}
}

接口配置

@Configuration
public class WebserviceConfig {@Autowiredprivate ServerService serverService;/*** 重命名发布的web service的访问路径* 注入servlet  bean name不能用dispatcherServlet 否则会覆盖dispatcherServlet** @return*/@Bean(name = "cxfServlet")public ServletRegistrationBean cxfServlet() {return new ServletRegistrationBean(new CXFServlet(), "/webservice/*");}@Bean(name = Bus.DEFAULT_BUS_ID)public SpringBus springBus() {return new SpringBus();}/*** 注册ServerService接口到webservice服务** @return*/@Beanpublic Endpoint ServerServiceEndPoint() {EndpointImpl endpoint = new EndpointImpl(springBus(), serverService);endpoint.publish("/ServerService");return endpoint;}
}

可以直接再我的git上下载工程使用。
https://gitee.com/kenyon511/blood-api


http://www.ppmy.cn/news/127571.html

相关文章

mx550和锐炬xe显卡差距大 锐炬xe显卡和mx550区别哪个好

mX550是NVIDIA面向轻薄本平台推出全新独立显卡&#xff0c;性能比上一代MX450提升了34%。 mx550显卡是基于12nm工艺制程&#xff0c;Turing架构设计的显卡&#xff0c;并采用TU117显示核心设计&#xff0c;支持PCIe 4.0&#xff0c;具备1024个CUDA单元&#xff0c;并搭配有2GB容…

锐炬显卡和mx450独显哪个好

MX450独显好。原因如下&#xff1a; 选锐炬显卡还是mx450这些点很重要 http://www.adiannao.cn/dq 1、MX450 2G独立显卡是英伟达 出品的独立显卡&#xff0c;自带2G显存&#xff0c;性能高于锐炬核芯显卡。但是功耗也高于锐炬核芯显卡。 2、锐炬显卡是intel CPU之中集成的核芯…

t600显卡和p620哪个好

t600显卡其CUDA处理核心为896&#xff0c;显存带宽最大为160GB/s&#xff0c;显存类型为GDRR6,4GB的显存&#xff0c;位宽为128bit 选 t600显卡还是p620这些点很重要 http://www.adiannao.cn/dq P620是一款适用于笔记本电脑的入门级移动工作站显卡&#xff0c;NVIDIA Quadro P6…

显卡选购

显卡 1.流处理器的数量&#xff08;越多越好&#xff09; 2.新架构的显卡效率更高 &#xff08;最新的图灵架构具有深度学习的能力&#xff09; 3.显卡的核心频率 &#xff08;越高越好&#xff09; 4.显存容量&#xff08;存储大小&#xff0c;并不是最重要的&#xff09; 位…

T600显卡和GTX1650 哪个好

GTX1650采用TU117-300&#xff08;图灵架构&#xff09;核心&#xff0c;12nm制程工艺&#xff0c;CUDA核心896个&#xff0c;显存类型DDR5和DDR6&#xff0c;显存频率8000MHz&#xff0c;显存位宽128bit&#xff0c;显存容量4GB&#xff0c;最大分辨率7680x4320&#xff0c;TD…

2021最新的NVIDIA显卡排行榜前十

说起英伟达的显卡&#xff0c;很多人都不陌生&#xff0c;现在很多电脑显卡硬件都是使用的英伟达或者amd的显卡。而NVIDIA显卡的种类和型号很多&#xff0c;不同的显卡性能也不同。那么从独显来看&#xff0c;比较好的NVIDIA显卡有哪些呢&#xff1f;下面小编就给大家分享下202…

【数据结构与算法】力扣:栈和队列(一)

1 请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作&#xff08;push、pop、peek、empty&#xff09;&#xff1a; 实现 MyQueue 类&#xff1a; void push(int x) 将元素 x 推到队列的末尾 int pop() 从队列的开头移除并返回元素 int peek() 返回队列开…

NVIDIA显卡型号有哪些?怎么知道自己电脑的型号?

NVIDIA显卡型号 显卡分N卡和A卡&#xff0c;这个N卡指的是英伟达&#xff08;NVIDIA&#xff09;&#xff0c;A卡之前是ATI&#xff08;后来被AMD收购&#xff09;&#xff0c;现在的A卡指的就是AMD显卡。如果是为了玩游戏或者是学深度学习&#xff0c;选显卡肯定是要选N卡&am…