文档文库
手机版
投诉建议
热门搜索:
心得体会
演讲稿
思想汇报
首页
心得体会
学习心得体会
培训心得体会
军训心得体会
社会实践
作风建设
工作心得体会
教育心得体会
演讲稿
演讲稿格式
演讲稿范文
竞聘演讲稿
师德演讲稿
三分钟演讲稿
思想汇报
思想汇报范文
转正思想汇报
大学生思想汇报
季度思想汇报
教师思想汇报
工作计划
工作计划格式
工作计划开头
工作计划结尾
总结与计划
工作计划模板
工作总结
年终工作总结
年度工作总结
个人工作总结
实习报告
实习报告范文
实习计划范文
实习鉴定范文
实习报告内容
个人简历
求职简历
简历范文
简历模板
简历表格
简历格式
祝福语
春节
除夕
元宵
端午节
合同范文
合同范本
合同样本
合同范本格式
首页
>
springboot+cxf 搭建webservice接口项目
springboot+cxf 搭建webservice接口项目
发布时间:2020-03-19 来源:
文档文库
小
中
大
字号:
手机查看
一、
项目开发环境
1.jdk 1.8
2.springboot 2.0.3
3.cxf
3.2.6
注意:
springboot
版本过高可能会和
cxf
冲突
导致项目启动报错
二、
搭建
1.
创建项目后添加以下依赖
org.springframework.boot
spring-boot-starter-parent
2.0.3.RELEASE
3.1.1
1.8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-test
test
org.apache.cxf
cxf-spring-boot-starter-jaxws
3.2.6
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-compiler-plugin
1.8
1.8
UTF-8
2.
创建一个接口类
@WebService(targetNamespace
=
"http://xxx.xxx.xxx/"//
命名空间
,
一般是接口
的包名倒序
public interface TestService {
@WebMethod
public String test(@WebParam(name = "userName" String name;
}
之后创建接口的实现类
public class TestServiceImpl implements TestService {
@Override
public String test(String name {
// TODO Auto-generated method stub
return "hellow";
}
}
3.
创建
cxfconfig
配置类
package com.gsww.chis.config;
import javax.xml.ws.Endpoint;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
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 com.gsww.chis.webservice.TestService;
import com.gsww.chis.webservice.impl.TestServiceImpl;
@Configuration
public class CxfConfig {
@Bean(name = Bus.DEFAULT_BUS_ID
public SpringBus springBus( {
return new SpringBus(;
}
/**
*
此方法被注释后
:wsdl
访问地址为
http://127.0.0.1:8080/services/user?wsdl
*
去掉注释后:
wsdl
访问地址为:
http://127.0.0.1:8080/soap/user?wsdl
*/
@SuppressWarnings({ "rawtypes", "unchecked" }
@Bean
public ServletRegistrationBean dispatcherServlet( {
return new ServletRegistrationBean(new CXFServlet(, "/soap/*";
}
@Bean
public TestService testService( {
return new TestServiceImpl(;
}
/**
*
发布服务
指定访问
url
*
* @return
*/
@Bean
public Endpoint userEndpoint( {
EndpointImpl endpoint = new EndpointImpl(springBus(, testService(;
endpoint.publish("/call";
System.out.println("
发布成功
";
return endpoint;
}
}
3.
访问路径
ip:
端口
/
(项目配置的
context-path
)
/soap/call?wsdl
本文来源:
https://www.2haoxitong.net/k/doc/5ca26ddfa66e58fafab069dc5022aaea988f414d.html
《springboot+cxf 搭建webservice接口项目.doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档
文档为doc格式
分享到:
相
关
案
例
安全验证
2024-04-30
安全验证
2024-04-30
正在进行安全检测...
2024-04-30
正在进行安全检测...
2024-04-30
正在进行安全检测...
2024-04-30
正在进行安全检测...
2024-04-30
正在进行安全检测...
2024-04-30
正在进行安全检测...
2024-04-30
正在进行安全检测...
2024-04-30
正在进行安全检测...
2024-04-30
相关推荐
1
自制酸奶的方法步骤
2
“搭客佬”想对自己儿子说的话
3
八年级上册政治知识结构 2
4
云南省教育厅关于普通中小学校办学行为的若干规定 试行
5
安全生产月活动的个人总结(最新)
6
科普知识资料
7
核能专业词汇英语翻译(F-L)
8
驳张仲景官居长沙太守的三项依据
9
保障劳动者权益正确理解单位聘用关系
10
The unforgettable day with love 感人的故事
推荐内容
更换老师申请书
部编版二年级语文上册全册生字组词
国家基金申请项目合作协议模版
关于校园文化活动调研的策划书
主任2017年年中工作会议发言稿
在初中语文教学中如何实施创新教育论文
最新傣族孔雀舞观后感
2016年武汉市初中毕业生学业考试方案
五年级上第四单元形成性测试参赛试卷附答案
2021防疫知识竞赛题库