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... ...
随机推荐
- easyEZbaby_app
for循环,这里给它化简255-i+2-98-未知数x需要等于'0'对应的ASCII值48,那么求x的值,x=111-i,而i的值就是从0到14,这样便可以计算出15位的密码 所以写出来的脚本
- PZthon
一道新式题目,python.exe的分析 这个时候没有思路不要紧,直接wp 先用特别的软件执行.exe程序,就是对.exe进行反编译 然后在反编译脚本的目录写就有了一个打包文件夹 在里面找到文件的.p ...
- C语言输入若干个正整数(输入-1为结束标志),要求按输入数据的逆序建立单链表并输出。
/* 开发者:慢蜗牛 开发时间:2020.6.11 程序功能:逆序建立链表,顺序输出 */ #include<stdio.h> #include<malloc.h> #defi ...
- 8.0的新特性 -- invisible(不可见索引)
版权声明:原创作品,谢绝转载!否则将追究法律责任. ----- 作者:kirin invisible index 不可见索引 以前的版本,假如这个索引无用了会怎么样?那就只能是drop掉了.但是dro ...
- 【Javaweb】什么是Listener监听器?
1.Listener监听器它是Javaweb的三大组件之一.Javaweb的三大组件分别是:Servelt程序,Filter过滤器,Listener监听器. 2.Listener它是JavaEE的规范 ...
- 【Javaweb】Servlet三|实现Servlet程序的几种方法及Servlet继承体系说明
GET和POST请求的分发处理 代码如下 注意页面要和index位置一样否则浏览器找不到 注意大小写 HttpServletRequest httpServletRequest = (HttpServ ...
- 最好用的oa办公系统?
OA办公系统是一种集成办公自动化.协同办公.信息管理等功能于一体的软件系统,旨在提高办公效率,优化流程管理,提供更好的团队协作和信息共享.下面将详细介绍几个目前市场上认为较为优秀的OA办公系统. 一. ...
- Vue3+Vite+ElementPlus管理系统常见问题
本文本记录了使用 Vue3+Vite+ElementPlus 从0开始搭建一个前端工程会面临的常见问题,没有技术深度,但全都是解决实际问题的干货,可以当作是问题手册以备后用.本人日常工作偏后端开发,因 ...
- Kernel Memory 入门系列:Kernel Memory Service
Kernel Memory 入门系列:Kernel Memory Service 在 Kernel Memory 的 GitHub 仓库中有一个单独的项目 Service , 用于提供独立的Kerne ...
- 从零玩转Java和word模板-从零玩转java和word模板
title: 从零玩转Java和word模板 date: 2021-12-22 18:38:14.086 updated: 2021-12-22 18:38:14.086 url: https://w ...