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... ...
随机推荐
- 手撕Vuex-模块化共享数据下
前言 好,经过上一篇的介绍,了解了 Vuex 当中的模块化,本章主要介绍 Vuex 当中的模块化共享数据下篇. 我们知道在全局的 Store 对象当中,我们可以定义全局的数据,那么如果我们在模块当中也 ...
- 关于RS485通讯TVS器件选择的经验
先说经验结论 如果你的RS485用于频繁热拔插, 比如作为手持终端使用, 且手持器与目标板非隔离, 那么使用6.8CA可能是更好的选择. 因为有热拔插会产生浪涌, 而且在非隔离的场合有些工业设备接地也 ...
- php开发之文件上传的实现
前言 php是网络安全学习里必不可少的一环,简单理解php的开发环节能更好的帮助我们去学习php以及其他语言的web漏洞原理 正文 在正常的开发中,文件的功能是必不可少,比如我们在论坛的头像想更改时就 ...
- 火山引擎 DataLeap 计算治理自动化解决方案实践和思考
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 [导读]本文旨在探讨火山引擎 DataLeap 在处理计算治理过程中所面临的问题及其解决方案,并展示这些解决方案带 ...
- 由后缀表达式题目:stoi atoi 函数新发现
洛谷上的题:有些·表示一个操作结束~假装没看到 1 #include<iostream> 2 #include<stack> 3 #include<string> ...
- 4G打猎摄像机拆机分析
前言 收到一台4G打猎相机,官方外观及功能图片如下所示,现对该设备进行拆机及整体技术分析评估,看我们可以从中学习到什么. (一)什么是打猎相机 所谓打猎相机,也叫野外相机,专门用于野外观察和监测野生动 ...
- SQL 语言标准简介
版权声明:原创作品,谢绝转载!否则将追究法律责任. ----- 作者:kirin 一.简介 结构化查询语言(Structured Query Language)简称SQL,是一种特殊目的的编程语言,是 ...
- Aiganize组局小程序开发手册
1. 开发阶段概述: 第一阶段: 针对组局和参局的产品功能落地完善小程序, 修改前端界面,去除冗余, 完善数据库设计 完善组局参局的功能 让每个用户能参与组局大厅的组局 让用户能申请为组局者发起组局, ...
- SpringBoot Seata 死锁问题排查
现象描述:Spring Boot项目,启动的时候卡住了,一直卡在那里不动,没有报错,也没有日志输出 但是,奇怪的是,本地可以正常启动 好吧,姑且先不深究为什么本地可以启动而部署到服务器上就无法启动的问 ...
- JXNU acm选拔赛 最小的数
最小的数 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Submissi ...