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 及 注意项的更多相关文章

  1. springboot IDEA新建Maven项目的Plugins出现红线的解决方法

    将pom.xml文件copy到桌面,删除项目中的pom.xml.发现项目maven中没有任何东西后,然后将桌面的pom.xml粘贴到项目目录下,刷新maven就ok了

  2. SpringBoot系列: Java应用程序传参和SpringBoot参数文件

    ===========================向java 程序传参的几种形式:===========================1. 使用 OS 环境变量. 这个不推荐. 2. 使用JVM ...

  3. Springboot+MyBatis+JPA集成

      1.前言 Springboot最近可谓是非常的火,本人也在项目中尝到了甜头.之前一直使用Springboot+JPA,用了一段时间发现JPA不是太灵活,也有可能是我不精通JPA,总之为了多学学Sp ...

  4. 集成Springboot+MyBatis+JPA

    1.前言 Springboot最近可谓是非常的火,本人也在项目中尝到了甜头.之前一直使用Springboot+JPA,用了一段时间发现JPA不是太灵活,也有可能是我不精通JPA,总之为了多学学Spri ...

  5. springboot启动流程(七)ioc容器refresh过程(上篇)

    所有文章 https://www.cnblogs.com/lay2017/p/11478237.html 正文 在前面的几篇文章中,我们看到Environment创建.application配置文件的 ...

  6. idea springboot 使用JRebel热部署

    1.首先在idea中下载jrebel.由于已经下载过了.上这样 2.下载jrebel破解插件 https://gitee.com/gsls200808/JrebelLicenseServerforJa ...

  7. Springboot学习:介绍与HelloWorld

    1. 什么是 Spring boot Spring Boot来简化Spring应用开发,约定大于配置,去繁从简,just run就能创建一个独立的,产品级别的应用 整个Spring技术栈的一个大整合 ...

  8. SpringBoot 配置文件使用详解

    一.创建一个SpringBoot项目 创建 SprintBoot 项目的 2 种方式: 在 https://start.spring.io/ 上创建一个 SpringBoot 项目,然后导入到 IDE ...

  9. SpringBoot 08: SpringBoot综合使用 MyBatis, Dubbo, Redis

    业务背景 Student表 CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) COL ...

  10. spring cloud 学习(8) - sleuth & zipkin 调用链跟踪

    业务复杂的微服务架构中,往往服务之间的调用关系比较难梳理,一次http请求中,可能涉及到多个服务的调用(eg: service A -> service B -> service C... ...

随机推荐

  1. 解决Pycharm运行成功,但无法生成:pytest-html报告

    不生成报告的原因: 用户习惯:使用者习惯于单独执行测试文件.py,调试测试用例: 而编辑器为了方便用户执行测试用例,变调用python test来执行测试用例,这种情况下,执行的只是用例或者套件,不是 ...

  2. KingabseES例程-事实数据与规则的匹配校验

    KingabseES例程-事实数据与规则的匹配校验 背景 使用规则,对数据进行校验,比如电商的用户购物订单,是否合法.这就需要订单的多维度,如 用户.地区.物流.支付手段.供应商 等各类信息,进行动态 ...

  3. upload—labs

    首先 常见黑名单绕过 $file_name = deldot($file_name);//删除文件名末尾的点上传 shell.php. $file_ext = strtolower($file_ext ...

  4. 微服务系列-Spring Boot使用Open Feign 微服务通信示例

    公众号「架构成长指南」,专注于生产实践.云原生.分布式系统.大数据技术分享. 前言 在前几个教程中我们已经看到: 使用 RestTemplate 的 Spring Boot 微服务通信示例 使用 We ...

  5. Codeforces Global Round 13 A-D题题解

    写在前边 链接:Codeforces Global Round 13 \(A,B,C,D\) A. K-th Largest Value 链接:A题链接 题目大意: 有一个字串只由\(0.1\)组成, ...

  6. 基于TensorFlow 2与PaddlePaddle 2预测泰坦尼克号旅客生存概率的比较

    ​  目录 1,程序比较 2,训练过程对比: 3,训练结果对比 AI框架经过大浪淘沙之后,目前真正能够完整用于生产.科研.学术的只剩下了谷歌.脸书.百度三家的框架,本文通过一个泰坦尼克号旅客生存概率预 ...

  7. 【Android Studio】 SQLite 数据库 增删改查

    今日目标:参照标题 实现效果: 实现过程: 1.创建实现页面 页面设计思路: 最外层垂直线性布局.内部使用三个线性布局.后两个用的水平排版,用来显示数值. 实例化四个Button,两个EditText ...

  8. 架构师的知行合一(内容由AI的全文生成,满分100分我打99分)

    大型架构是怎么来的 随着科技的不断发展,越来越多的企业和组织开始意识到数字化转型的重要性.为了更好地适应市场的变化,满足客户的需求,提高企业的竞争力,大型架构成为了企业和组织不可或缺的一部分.那么,大 ...

  9. [CF1364E] X-OR

    X-OR 题面翻译 题目描述 本题是交互题. 有一个固定的长度为 \(n\) 的排列 \(P\),其值域为 \([0,n-1]\),你可以进行不超过 \(4269\) 次询问,之后你需要输出这个排列 ...

  10. [ABC272G] Yet Another mod M

    Problem Statement You are given a sequence $A=(A_1,A_2,\dots,A_N)$ of length $N$ consisting of posit ...