pom.xml文件引入包:

<!--WerbService CXF依赖-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.12</version>
</dependency>

  

  模拟代码:

package webServiceDemo;

import java.io.Serializable;

/**
* TODO
* 实体类
*/
public class User implements Serializable { private String name; private String age; private String xb; public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getAge() {
return age;
} public void setAge(String age) {
this.age = age;
} public String getXb() {
return xb;
} public void setXb(String xb) {
this.xb = xb;
} public User() {
} public User(String name, String age, String xb) {
this.name = name;
this.age = age;
this.xb = xb;
}
}

  

package webServiceDemo;

import javax.jws.WebMethod;
import javax.jws.WebService; /**
* TODO
* webService接口
*/
@WebService
public interface UserWebService { @WebMethod
User getUserByName(String name);
}

  

package webServiceDemo;

import javax.jws.WebService;
import java.util.ArrayList;
import java.util.List; /**
* TODO
* webService接口实现类
* endpointInterface为UserWebService所在项目地址(包含接口名),targetNamespace为UserWebService所在项目地址倒序(不含接口名) 
*/
@WebService(targetNamespace = "http://webServiceDemo/", endpointInterface = "webServiceDemo.UserWebService")
public class UserWebServiceImpl implements UserWebService { @Override
public User getUserByName(String name) {
List<User> userList = new ArrayList<>();
User user1 = new User("张三", "21", "男");
userList.add(user1);
User user2 = new User("李四", "19", "女");
userList.add(user2);
User needUser = new User();
for (User user : userList) {
if (!user.getName().equals(name)) {
continue;
}
needUser = user;
} return needUser;
}
}

  

package webServiceDemo;

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; /**
* TODO
* WebService服务发布配置
*/
@Configuration
public class WebServiceConfig { @Bean
public ServletRegistrationBean disServlet(){
return new ServletRegistrationBean(new CXFServlet(), "/service/*"); //发布服务名称
} @Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus()
{
return new SpringBus();
} @Bean
public UserWebService userWebService() {
return new UserWebServiceImpl();
} /*
WebService服务发布
*/
@Bean
public Endpoint endpoint() {
//绑定要发布的服务
EndpointImpl endpoint = new EndpointImpl(springBus(), userWebService());
endpoint.publish("/userWebService"); //显示要发布的名称
return endpoint;
}
}

  

  然后启动项目,创建的WebService服务会随着项目启动发布,启动成功后,根据发布配置浏览器访问:

http://localhost:8080/service/userWebService?wsdl

  构建服务端参考资料:

  https://www.cnblogs.com/xibei666/p/8970549.html

  https://blog.csdn.net/cs_hnu_scw/article/details/80181762

  https://www.imooc.com/article/25537?block_id=tuijian_wz

  遇到的问题及解决办法:

  https://www.cnblogs.com/Big-Boss/p/11912679.html

  

Spring Boot+CXF搭建WebService服务参考资料的更多相关文章

  1. Spring Boot+CXF搭建WebService(转)

    概述 最近项目用到在Spring boot下搭建WebService服务,对Java语言下的WebService了解甚少,而今抽个时间查阅资料整理下Spring Boot结合CXF打架WebServi ...

  2. Spring Boot+CXF搭建WebService

    Spring Boot WebService开发 需要依赖Maven的Pom清单 <?xml version="1.0" encoding="UTF-8" ...

  3. Spring boot+CXF开发WebService

    最近工作中需要用到webservice,而且结合spring boot进行开发,参照了一些网上的资料,配置过程中出现的了一些问题,于是写了这篇博客,记录一下我这次spring boot+cxf开发的w ...

  4. Spring boot+CXF开发WebService Demo

    最近工作中需要用到webservice,而且结合spring boot进行开发,参照了一些网上的资料,配置过程中出现的了一些问题,于是写了这篇博客,记录一下我这次spring boot+cxf开发的w ...

  5. Spring Boot 实现RESTful webservice服务端实例

    1.Spring Boot configurations application.yml spring: profiles: active: dev mvc: favicon: enabled: fa ...

  6. Spring Boot 实现RESTful webservice服务端示例

    1.Spring Boot configurations application.yml spring: profiles: active: dev mvc: favicon: enabled: fa ...

  7. Maven+Spirng+Mybatis+CXF搭建WebService服务

    https://jingyan.baidu.com/article/39810a23b1de2fb637fda66c.html

  8. struts1+spring+myeclipse +cxf 开发webservice以及普通java应用调用webservice的实例

    Cxf + Spring+ myeclipse+ cxf 进行  Webservice服务端开发 使用Cxf开发webservice的服务端项目结构 Spring配置文件applicationCont ...

  9. CXF发布webService服务以及客户端调用

    这篇随笔内容是CXF发布webService服务以及客户端调用的方法 CXF是什么? 开发工作之前需要下载CXF和安装 下载地址:http://cxf.apache.org 安装过程: <1&g ...

随机推荐

  1. bzoj 4899 记忆的轮廓 题解(概率dp+决策单调性优化)

    题目背景 四次死亡轮回后,昴终于到达了贤者之塔,当代贤者夏乌拉一见到昴就上前抱住了昴“师傅!你终于回来了!你有着和师傅一样的魔女的余香,肯定是师傅”.众所周知,大贤者是嫉妒魔女沙提拉的老公,400年前 ...

  2. LOJ #2734 Luogu P3615 [JOI2016春季合宿]Toilets (结论、贪心)

    题目链接 (loj) https://loj.ac/problem/2734 (luogu) https://www.luogu.org/problem/P3615 题解 嗯,考场上肝了\(3h\)然 ...

  3. Zookeeper 安装及命令行操作

    [参考文章]:[分布式]Zookeeper使用--命令行 [参考文章]:zookeeper的数据模型 [参考文章]:zookeeper ACL使用 1. 安装包下载 官方下载地址 选择一个具体的版本进 ...

  4. Mac securecrt 破解

      今天花了好长的时间终于在Mac上把SecureCRT安装成功了,网上教程大多没有截图,破解关键步骤含糊,现在把详细的破解过程和SecureCRT使用教程分享给大家.最后把参考的博客连接附在最下方. ...

  5. HearthBuddy卡牌无法识别

    界面上无法识别,提示是 [Unidentified card ID :DAL_010][Unidentified card ID :DAL_415] Unidentified card ID :HER ...

  6. yum 时一直停在Determining fastest mirrors 界面

    [root@fanyk ~]# yum redis Loaded plugins: fastestmirror Determining fastest mirrors 在yum makecache时, ...

  7. 云服务器 ECS 是什么?

    云服务器 Elastic Compute Service(ECS)是阿里云提供的一种基础云计算服务.使用云服务器 ECS 就像使用水.电.煤气等资源一样便捷.高效.您无需提前采购硬件设备,而是根据业务 ...

  8. Appium移动自动化测试(一)之环境配置

    移动自动化测试很多公司首选appuim, 要了解它的特点和优势请移步http://www.testclass.net/appium/appium-base-summary/ 要开始自动化测试, 好多人 ...

  9. 190628 - 解决新版本LastPass没有谷歌套件时打开就闪退的问题.md

    目录 解决新版本LastPass没有谷歌套件时打开就闪退的问题 可用解决方案 可用解决方案3 可用解决方案2 可用解决方案1 尝试安装 碰到的问题列表 问题现象 解决新版本LastPass没有谷歌套件 ...

  10. linux之磁盘管理,网络,计时任务

    磁盘管理 查看磁盘空间的占用 df # 磁盘占有率 -h # 以人类易读的方式展示 Linux下磁盘命名格式:/dev/sda 查看目录的占用空间 /dev/sd[a-z]num总大小 linux下磁 ...