1 Star 0 Fork 0

houzw/webservice-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Axis2

Apache CXF

+Spring-boot

注意: 若配置了指定的服务描述框架,如cxf-rt-rs-service-description-swaggercxf-rt-rs-service-description-openapi-v3 则需要加上cxf-rt-rs-service-description依赖,默认的服务列表页面才会出现, service-list-path才能有效。不然报 404 错误

restful 服务配置

http://cxf.apache.org/docs/springboot.html

手动配置

在 java 的 配置类中

//    restful web service

@Autowired
private CxfRsService rsService;
@Bean
public Server rsServer() {
    final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
    endpoint.setProvider(new JacksonJsonProvider());
    endpoint.setAddress("/rs");
//      endpoint.setServiceBeans(Arrays.<Object>asList());
    endpoint.setServiceBean(rsService);
    endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
    return endpoint.create();
}

自动配置

在项目的application.yml中,

cxf:
  jaxrs:
    component-scan: true
    classes-scan-packages: org.apache.cxf.jaxrs.swagger,com.vtech.ws.cxf

web service

ws 为 context,rs 为 手动配置restful服务时的地址

默认服务列表地址:'http://host:port/context/services/services' (最后面的services可以通过cxf.servlet.init.service-list-path属性修改, 如http://localhost:8008/ws/services/list

soap: http://localhost:8008/ws/services/info?wsdl (java 配置)

  http://localhost:8008/ws/services/HiService?wsdl (xml配置)

rest: http://localhost:8008/ws/services/rs/sayHello/cxf ( rs 为 endpoint地址,如果指定了的话。最后的cxf为输入参数);

   http://localhost:8008/ws/services/rs/swagger.json

CXF Swagger

  • application.yaml配置文件中配置启动swagger

  • 使用 swagger.properties 配置 swagger

  • 在endpoint 地址后加swagger.jsonswagger.yaml

    如,若 JAX-RS endpoint 发布地址为 http://host:port/context/services/, 'context' 是应用程序上下文目录, "/services" 是 servlet URL, Swagger documents 则为 http://host:port/context/services/swagger.jsonhttp://host:port/context/services/swagger.yaml'

  • swagger-ui 'http://host:port/context/services/api-docs/?url=/swagger.json' 或
    'http://host:port/context/services/services' 页面中也有swagger-ui 的链接

设置 Swagger2Feature 的 'supportSwaggerUi' 为'false'取消对UI的激活

Rest 服务文件上传下载

CXF 教程

空文件

简介

Web service demos use cxf 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/vtech/webservice-demo.git
git@gitee.com:vtech/webservice-demo.git
vtech
webservice-demo
webservice-demo
master

搜索帮助