Spring Boot+CXF搭建WebService服务参考资料
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服务参考资料的更多相关文章
- Spring Boot+CXF搭建WebService(转)
概述 最近项目用到在Spring boot下搭建WebService服务,对Java语言下的WebService了解甚少,而今抽个时间查阅资料整理下Spring Boot结合CXF打架WebServi ...
- Spring Boot+CXF搭建WebService
Spring Boot WebService开发 需要依赖Maven的Pom清单 <?xml version="1.0" encoding="UTF-8" ...
- Spring boot+CXF开发WebService
最近工作中需要用到webservice,而且结合spring boot进行开发,参照了一些网上的资料,配置过程中出现的了一些问题,于是写了这篇博客,记录一下我这次spring boot+cxf开发的w ...
- Spring boot+CXF开发WebService Demo
最近工作中需要用到webservice,而且结合spring boot进行开发,参照了一些网上的资料,配置过程中出现的了一些问题,于是写了这篇博客,记录一下我这次spring boot+cxf开发的w ...
- Spring Boot 实现RESTful webservice服务端实例
1.Spring Boot configurations application.yml spring: profiles: active: dev mvc: favicon: enabled: fa ...
- Spring Boot 实现RESTful webservice服务端示例
1.Spring Boot configurations application.yml spring: profiles: active: dev mvc: favicon: enabled: fa ...
- Maven+Spirng+Mybatis+CXF搭建WebService服务
https://jingyan.baidu.com/article/39810a23b1de2fb637fda66c.html
- struts1+spring+myeclipse +cxf 开发webservice以及普通java应用调用webservice的实例
Cxf + Spring+ myeclipse+ cxf 进行 Webservice服务端开发 使用Cxf开发webservice的服务端项目结构 Spring配置文件applicationCont ...
- CXF发布webService服务以及客户端调用
这篇随笔内容是CXF发布webService服务以及客户端调用的方法 CXF是什么? 开发工作之前需要下载CXF和安装 下载地址:http://cxf.apache.org 安装过程: <1&g ...
随机推荐
- 关于MapReduce的测试
题目:数据清洗以及结果展示 要求: Result文件数据说明: Ip:106.39.41.166,(城市) Date:10/Nov/2016:00:01:02 +0800,(日期) Day:10,(天 ...
- P1598 垂直柱状图
输入格式: 四行字符,由大写字母组成,每行不超过100个字符 输出格式: 由若干行组成,前几行由空格和星号组成,最后一行则是由空格和字母组成的.在任何一行末尾不要打印不需要的多余空格.不要打印任何空行 ...
- 原生Js_实现广告弹窗
广告样式当页面加载后5s刷新在右下角 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...
- [BZOJ2208]:[Jsoi2010]连通数(暴力 or bitset or 塔尖?)
题目传送门 题目描述 度量一个有向图连通情况的一个指标是连通数,指图中可达顶点对的个数. 在上图中,顶点1可以到达1.2.3.4.5. 顶点2可以到达2.3.4.5. 顶点3可以到达3.4.5. 顶点 ...
- idea 远程代码调试
声明一点:重要的事情说3遍 本地代码和服务器代码必须一致 本地代码和服务器代码必须一致 本地代码和服务器代码必须一致 第一步,创建remote 第二步.填写服务器信息 第三部.tomcat/bin/s ...
- Telnet/SSH 客户端
一.WinSCP linux 与 windows 间传递文件.可以与 putty 配合使用. 官网提供便携版下载:https://winscp.net/eng/downloads.php 支持中文,语 ...
- Python中列表的使用
python中的列表与java中的数组非常类似,但使用方法比java中数组简单很多,python中的数据类型不需要显示声明,但在使用时必须赋值,列表元素下标从0开始 初始化列表(初始化一个包含五个元素 ...
- pandas.Series.value_counts
pandas.Series.value_counts Series.value_counts(normalize=False, sort=True, ascending=False, bins=Non ...
- python全栈开发第7天 nginx服务器和nfs的搭建及组成集群的方法
作业一:nginx服务 二进制安装nginx包 1.使用命令:yum install epel-release -y ,来安装epel,安装成功如下图:(因为我用32位的centos7老是出现各种各样 ...
- 微服务一键启动脚本shell带有环境变量的
etting####################################################### #程序代码数组APPS=(cAssistantbussiness cAssi ...