springboot配置cxf
1.引入两个需要的jar
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.</version>
</dependency>
2.配置webservice类
package com.btw.court.webService; import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService; @WebService
public interface PayWebService { @WebMethod
String say(@WebParam(name="arg0")String arg0); }
3.配置webservice实现类
package com.btw.court.webService.impl; import com.btw.court.webService.PayWebService; import javax.jws.WebService; @WebService(targetNamespace = "http://say.com")//对应wsdl中的命名空间xmlns:tns
public class PayWebServiceImpl implements PayWebService { @Override
public String say(String arg0) {
return null;
} }
4.配置springboot配置类
package com.btw.court.config; import com.btw.court.webService.PayWebService;
import com.btw.court.webService.impl.PayWebServiceImpl;
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 WebServiceConfig { @Bean//发布服务名称,可以访问该路径查看拥有的webservice
public ServletRegistrationBean dispathcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/service/*");
} @Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
} @Bean
public PayWebService payWebService() {
return new PayWebServiceImpl();
} /**
* 绑定接口类,描述接口实现方法,以及接口名称.如果有多个接口需要实现,可以添加多个该方法(设置方法名不同,发布路径不同即可)
* @return
*/
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(springBus(), payWebService());
endpoint.publish("/ws");
return endpoint;
}
}
此时,我们输入http://ip:port/service,可以看到如下图所示内容。左侧马赛克为接口包含的方法,右侧为接口的描述,包括发布地址、wsdl和命名空间。

点击wsdl的路径,可以看到接口的详细描述。
springboot配置cxf的更多相关文章
- SpringBoot配置属性之Server
SpringBoot配置属性系列 SpringBoot配置属性之MVC SpringBoot配置属性之Server SpringBoot配置属性之DataSource SpringBoot配置属性之N ...
- SpringBoot基础系列-SpringBoot配置
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9990680.html SpringBoot基础系列-SpringBoot配置 概述 属性 ...
- springboot上传文件 & 不配置虚拟路径访问服务器图片 & springboot配置日期的格式化方式 & Springboot配置日期转换器
1. Springboot上传文件 springboot的文件上传不用配置拦截器,其上传方法与SpringMVC一样 @RequestMapping("/uploadPicture&q ...
- springboot配置Druid数据源
springboot配置druid数据源 Author:SimpleWu springboot整合篇 前言 对于数据访问层,无论是Sql还是NoSql,SpringBoot默认采用整合SpringDa ...
- springboot配置详解
springboot配置详解 Author:SimpleWu properteis文件属性参考大全 springboot默认加载配置 SpringBoot使用两种全局的配置文件,全局配置文件可以对一些 ...
- SpringBoot 配置 Servlet、Filter、Listener
SpringBoot 配置 Servlet.Filter.Listener 在SpringBoot应用中,嵌入式的 Servlet 3.0+ 容器不会直接使用 ServletContainerInit ...
- SpringBoot 配置静态资源映射
SpringBoot 配置静态资源映射 (嵌入式servlet容器)先决知识 request.getSession().getServletContext().getRealPath("/& ...
- springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息
1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...
- SpringBoot配置(2) slf4j&logback
SpringBoot配置(2) slf4j&logback 一.SpringBoot的日志使用 全局常规设置(格式.路径.级别) SpringBoot能自动适配所有的日志,而且底层使用slf4 ...
随机推荐
- postgresql免密码登录
https://www.postgresql.org/docs/8.3/static/libpq-pgpass.html vi ~/.pgpass 输入以下内容 hostname:port:datab ...
- 帝国CMS 您来自的链接不存在
网上的解决方法如下. 我是在通过接口,发布新闻,然后点击修改的时候,提示这个. 网上的方法,是让检查这个栏目下,有没有设置默认模板,包括:列表模板和内容模板,如果没有,就设定一下,再“更新数据库缓 ...
- Winscp 密钥登录
继前段时间,使用密钥SSH登录系统以后运维用着很爽,但是有一部分开发的同事反应使用Winscp添加私钥的时候,提示添加失败,原来Winscp使用的是putty作为SSH登录工具,而puttygen所生 ...
- Python学习之旅(二十六)
Python基础知识(25):常用内建模块 1.datetime:处理日期和时间 (1)获取当前日期和时间 from datetime import datetime now = datetime.n ...
- JACKSON详解
Jackson 框架,轻易转换JSON Jackson可以轻松的将Java对象转换成json对象和xml文档,同样也可以将json.xml转换成Java对象. 前面有介绍过json-lib这个框架,在 ...
- sonarqube安装的坑
1.按照官网安装 结果启动不了,看了log日志以后,发现是es报错,不能以root权限启动
- 浅谈 pid的原理与差异
pid 官方语言就是:比例 积分 微分.究其本质意义,比例到底是什么,原理是什么,这三个到底如何在物理世界这种运作的,大概了解的人又很少.过惯了拿起数据公式无脑推的日子的人更是如此,数学公式是很 ...
- (四)juc线程高级特性——线程池 / 线程调度 / ForkJoinPool
13. 线程池 第四种获取线程的方法:线程池,一个 ExecutorService,它使用可能的几个池线程之一执行每个提交的任务,通常使用 Executors 工厂方法配置. 线程池可以解决两个不同问 ...
- [ipsec][strongswan] 用strongswan pki工具生成自签名证书
如题.我在实验环境里,分别要为两个endpoint(T9和T129)生成证书. 证书是如何生成的呢? 证书是由根证书机构签发的.申请证书的人将request提交给根证书机构,然后根证书机构根据requ ...
- python 中的__new__与__init__
在Python中的class中有两个方法__new__与__init__,有什么区别呢? class TestCls(): """docstring for TestCl ...