SpringBoot WebService 及 注意项
SpringBoot WebService 源代码:https://gitee.com/VipSoft/VipWebService
SpringBoot 版本 <version>2.3.0.RELEASE</version> <cxf.version>3.3.1</cxf.version> <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
package com.vipsoft.service; import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService; @WebService(name = "DemoWebService", // 暴露服务名称,不指定就会使用类名
targetNamespace = "http://service.his.vipsoft.com"// 与接口中的命名空间一致,一般是接口的包名倒 不加这个,SOAPUI 获取不到地址
)
public interface IDemoWebService { @WebMethod(action = "http://ws.vipsoft.com/sayHello") //有些集成平台,如果不加 action 会调不成功
public String sayHello(@WebParam(name = "arg") String arg);
}
package com.vipsoft.service.impl; import com.vipsoft.service.IDemoWebService;
import org.springframework.stereotype.Component; import javax.jws.WebService;
import java.util.Date; @Component
@WebService(serviceName = "DemoWebService", // 与接口中指定的name一致
targetNamespace = "http://service.his.vipsoft.com" // 与接口中的命名空间一致,一般是接口的包名倒
)
public class DemoWebServiceImpl implements IDemoWebService { @Override
public String sayHello(String arg) {
return arg + ",现在时间:" + "(" + new Date() + ")";
}
}
package com.vipsoft.web.config; import com.vipsoft.service.IDemoWebService;
import com.vipsoft.service.impl.DemoWebServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import javax.xml.ws.Endpoint; @Configuration
public class CxfConfig { @SuppressWarnings("all")
@Bean(name = "cxfServlet") //不加可能会报错
public ServletRegistrationBean cxfServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/ws/*");
} @Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
} @Bean
public IDemoWebService demoService() {
return new DemoWebServiceImpl();
} @Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(springBus(), demoService()); //绑定要发布的服务
endpoint.publish("/api"); // 暴露webService api,用在资源访问
return endpoint;
}
}
Error loading [http://localhost:9090/ws/api?wsdl]: java.lang.Exception: Load of url [http://localhost:9090/ws/api?wsdl] was aborted
WebService 不能使用 localhost 访问,可以通过 ipconfig 查看本机IP,使用IP进行访问
http://192.168.1.216:9090/ws/api?wsdl

SpringBoot WebService 及 注意项的更多相关文章
- springboot IDEA新建Maven项目的Plugins出现红线的解决方法
将pom.xml文件copy到桌面,删除项目中的pom.xml.发现项目maven中没有任何东西后,然后将桌面的pom.xml粘贴到项目目录下,刷新maven就ok了
- SpringBoot系列: Java应用程序传参和SpringBoot参数文件
===========================向java 程序传参的几种形式:===========================1. 使用 OS 环境变量. 这个不推荐. 2. 使用JVM ...
- Springboot+MyBatis+JPA集成
1.前言 Springboot最近可谓是非常的火,本人也在项目中尝到了甜头.之前一直使用Springboot+JPA,用了一段时间发现JPA不是太灵活,也有可能是我不精通JPA,总之为了多学学Sp ...
- 集成Springboot+MyBatis+JPA
1.前言 Springboot最近可谓是非常的火,本人也在项目中尝到了甜头.之前一直使用Springboot+JPA,用了一段时间发现JPA不是太灵活,也有可能是我不精通JPA,总之为了多学学Spri ...
- springboot启动流程(七)ioc容器refresh过程(上篇)
所有文章 https://www.cnblogs.com/lay2017/p/11478237.html 正文 在前面的几篇文章中,我们看到Environment创建.application配置文件的 ...
- idea springboot 使用JRebel热部署
1.首先在idea中下载jrebel.由于已经下载过了.上这样 2.下载jrebel破解插件 https://gitee.com/gsls200808/JrebelLicenseServerforJa ...
- Springboot学习:介绍与HelloWorld
1. 什么是 Spring boot Spring Boot来简化Spring应用开发,约定大于配置,去繁从简,just run就能创建一个独立的,产品级别的应用 整个Spring技术栈的一个大整合 ...
- SpringBoot 配置文件使用详解
一.创建一个SpringBoot项目 创建 SprintBoot 项目的 2 种方式: 在 https://start.spring.io/ 上创建一个 SpringBoot 项目,然后导入到 IDE ...
- SpringBoot 08: SpringBoot综合使用 MyBatis, Dubbo, Redis
业务背景 Student表 CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) COL ...
- spring cloud 学习(8) - sleuth & zipkin 调用链跟踪
业务复杂的微服务架构中,往往服务之间的调用关系比较难梳理,一次http请求中,可能涉及到多个服务的调用(eg: service A -> service B -> service C... ...
随机推荐
- Navicat Premium破解工具及教程
使用Navicat_Keygen_Patch5破解Navicat Premium 更新:2019-06-11 10:16 使用Navicat_Keygen_Patch_v5.0_By_DFoX破解Na ...
- 确定性有限状态自动机 DFA
前言 在计算理论中,确定有限状态自动机或确定有限自动机(英语:deterministic finite automaton, DFA)是一个能实现状态转移的自动机.对于一个给定的属于该自动机的状态和一 ...
- Kubernetes 漫游:kube-scheduler
概述 什么是 kube-scheduler ? Kubernetes 集群的核心组件之一,它负责为新创建的 Pods 分配节点.它根据多种因素进行决策,包括: 资源需求和限制:考虑每个 Pod 请求的 ...
- 分享一个LCD驱动框架
首先需要说明的是本篇文章不是关于如何点亮一块LCD屏的教程,而是介绍一个LCD开发框架,更准确的说是介绍一个LCD的中间件(Middlwware),用来连接UI和不同类型的LCD屏.笔者本人的工作内容 ...
- 【scikit-learn基础】--『数据加载』之玩具数据集
机器学习的第一步是准备数据,好的数据能帮助我们加深对机器学习算法的理解. 不管是在学习还是实际工作中,准备数据永远是一个枯燥乏味的步骤.scikit-learn库显然看到了这个痛点,才在它的数据加载子 ...
- h5移动端使用video实现拍照、上传文件对象、选择相册,做手机兼容。
html部分 <template> <div class="views"> <video style="width: 100vw; heig ...
- P8594 「KDOI-02」一个仇的复 题解
我会组合数! 首先发现同一列只有被不同的横块填或被一个相同的竖块填,且用竖块填完1列之后,会分成两个封闭的长方形,而长方形内部则用横块来填充. 先考虑一个子问题,某个 \(2 \times n\) 长 ...
- 一招MAX降低10倍,现在它是我的了
一.背景 性能优化是一场永无止境的旅程. 到家门店系统,作为到家核心基础服务之一,门店C端接口有着调用量高,性能要求高的特点. C端服务经过演进,核心接口先查询本地缓存,如果本地缓存没有命中,再查询R ...
- Chrome扩展开发系列开篇
大家好,我是 dom 哥.这是我关于 Chrome 扩展开发的系列文章,感兴趣的可以 点个小星星. 浏览器现状 研究机构 Statcounter 发布了 2023 年 9 月报告,揭示了有关浏览器的最 ...
- 数字孪生和GIS融合会为各自带来什么样的改变?
数字孪生和地理信息系统(GIS)是两个强大的技术,它们在各自领域发挥着重要作用.而当数字孪生与GIS融合时,将会为它们带来更加深远的改变和增益. 数字孪生技术以数字化的方式模拟和复制现实世界中的物理对 ...