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. 自定义Graph Component:1-开发指南

      可以使用自定义NLU组件和策略扩展Rasa,本文提供了如何开发自己的自定义Graph Component指南.   Rasa提供各种开箱即用的NLU组件和策略.可以使用自定义Graph Compo ...

  2. HBuilderX代码提示失效解决方案

    用了一段时间后,HBuilderX的代码提示功能突然不生效了,重新下载也没有用,解决方案是重置默认配置 提示:重置配置会清除编辑器内的项目,记得先保存 解决方案 1.找到HBuilderX根目录下的r ...

  3. tortoiseGit教程(常用图文教程)

    需求: gitTorise是git的比较好用的一个图形化工具,本文目的在于对tortoiseGit常见使用进行一个总结. 对于git常见的使用有: 1. 建立仓库 2. 提交代码 3. 更新代码 4. ...

  4. Maven的安装与配置本地仓库,镜像源,环境变量。

    参考视频: 黑马程序员2023新版JavaWeb开发教程,实现javaweb企业开发全流程 [小飞非系列]最新Maven实战教程-项目实战构建利器 一.下载Maven安装包 注意安装maven前要先安 ...

  5. Django学习(三) 之 模板中标签的使用

    写在前面 最近看到稀土掘金在搞2023年终总结征文活动,一直想尝试投稿试试,周末我就花了近一下午时间写完初稿,然后周一.周二完成精读再改稿,感觉OK,昨晚凌晨第一时间在稀土掘金投稿. 结果,又发生了同 ...

  6. 通过工厂函数封装返回app对象

    main.py #主文件 import os from app import create_app # 通过环境变量设置项目运行时使用的配置文件,这里就手动设置以下了,一般部署的时候通过脚本等设置. ...

  7. 解析RC4加密算法

    一.简介 RC4(Rivest Cipher 4)是一种对称加密算法,由Ronald L. Rivest于1987年为其所在的公司RSA Data Security Inc. 开发.作为一种可变密钥长 ...

  8. 【笔记】springSecurity-OAuth2.0-授权模式演示

    SpringSecurityOauth2架构 介绍 流程: 用户访问,此时没有Token.Oauth2RestTemplate会报错,这个报错信息会被Oauth2ClientContextFilter ...

  9. ubuntu frame 个人开发心得

    引言 有一次我在树莓派上安装 Ubuntu Core 我给创新创业项目开发一个可视化 gui 看板,用于展示数据. 然后我就找到了我需要的工具 Ubuntu Frame 初次尝试使用 Ubuntu F ...

  10. k8s主要概念大梳理!

    k8s已经成为了绝对热门的技术,一个上点规模的公司,如果不搞k8s,都不好意思出去见人.安装k8s要突破种种网络阻碍,但更大的阻碍还在后面... 我发现,很多k8s的文章,根本不说人话,包括那要命的官 ...