转载自:https://blog.csdn.net/qq_31451081/article/details/80783220

强推:https://blog.csdn.net/chjskarl/article/details/52052771

最好:    https://blog.csdn.net/xie19900123/article/details/83986482

第一种:

依赖:

 <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.5</version>
</dependency>
/**
* WebService接口
* @作者 Administrator
* @创建日期 2018/6/23 0023
* @创建时间 11:21.
*/
@WebService(name = "CommonService", // 暴露服务名称
targetNamespace = "http://www.WebService.demo.example.com") //命名空间,一般是接口的包名倒序
public interface CommonService {
@WebMethod
@WebResult(name = "String",targetNamespace = "")
public String HelloWorld(@WebParam(name = "HelloName") String name);
}
/**接口实现
* @作者 Administrator
* @创建日期 2018/6/23 0023
* @创建时间 11:26.
*/
@WebService(serviceName = "CommonService",//与前面接口一致
targetNamespace = "http://www.WebService.demo.example.com", //与前面接口一致
endpointInterface = "com.webservice.demo.webservice.CommonService") //接口地址
@Component
public class CommonServiceImpl implements CommonService {
@Override
public String HelloWorld(String name) {
return "Hello World!!! --->"+name;
}
}
public class CxfClient {
public static void main(String[] args) {
cl1();
} /**
* 方式1.代理类工厂的方式,需要拿到对方的接口
*/
public static void cl1() {
try {
// 接口地址
String address = "http://localhost:8080/services/CommonService?wsdl";
// 代理工厂
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
// 设置代理地址
jaxWsProxyFactoryBean.setAddress(address);
// 设置接口类型
jaxWsProxyFactoryBean.setServiceClass(CommonService.class);
// 创建一个代理接口实现
CommonService cs = (CommonService) jaxWsProxyFactoryBean.create();
// 数据准备
String userName = "Leftso";
// 调用代理接口的方法调用并返回结果
String result = cs.HelloWorld(userName);
System.out.println("返回结果:" + result);
} catch (Exception e) {
e.printStackTrace();
}
}
@Configuration
public class WebConfig {
@Autowired
private Bus bus; @Autowired
CommonService service; /*jax-ws*/
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, service);
endpoint.publish("/CommonService");
return endpoint;
}

第2种:

springboot整合webservice采用CXF技术的更多相关文章

  1. Springboot整合webservice

    Springboot整合webservice 2019-12-10 16:34:42 星期二 WebService是什么 WebService是一种跨编程语言和跨操作系统平台的远程调用技术,服务之间的 ...

  2. springboot整合WebService简单版

    一.什么是webservice 关于webservice的介绍摘自百度百科,上面的介绍很详细.(链接:https://baike.baidu.com/item/Web%20Service/121503 ...

  3. idea使用springboot的webservice基于cxf

    SpringBoot整合CXF实例: 服务端构建 <dependency> <groupId>org.apache.cxf</groupId> <artifa ...

  4. springboot 整合 CXF 版本异常 java.lang.NoClassDefFoundError:ServletRegistrationBean

    在使用SpringBoot 项目整合webservice组件 CXF的时候,在启动时,抛出异常如下,查阅资料初步判断为版本问题.升级到高版本后正常启动. cxf 刚开始使用版本  3.1.7 后更新为 ...

  5. SpringBoot 整合 MongoDB 实战介绍

    一.介绍 在前面的文章中,我们详细的介绍了 MongoDB 的配置和使用,如果你对 MongoDB 还不是很了解,也没关系,在 MongoDB 中有三个比较重要的名词:数据库.集合.文档! 数据库(D ...

  6. springboot项目搭建及常用技术整合

    一.在你建立的工程下创建 Module 选择Spring initializr创建. 二.在Type处选择: Maven Project(项目的构建工具) 三.创建依赖时勾上web,mybatis,m ...

  7. Spring整合CXF步骤,Spring实现webService,spring整合WebService

    Spring整合CXF步骤 Spring实现webService, spring整合WebService >>>>>>>>>>>> ...

  8. 【WebService】WebService之CXF和Spring整合(六)

    前面介绍了WebService与CXF的使用,项目中我们经常用到Spring,这里介绍CXF与Spring整合 步骤 1.创建一个Maven Web项目,可以参照:[Maven]Eclipse 使用M ...

  9. spring 与 CXF 整合 webservice 出现error “Unable to locate Spring NamespaceHandler for XML schema namespace” 总结

    我试了多个版本的spring 发现 出现error : Unable to locate Spring NamespaceHandler for XML schema namespace 并非都是sp ...

随机推荐

  1. 洛谷P2172 [国家集训队]部落战争 题解

    题目链接:https://www.luogu.org/problemnew/show/P2172 分析: 不要被[国家集训队]的标签吓到,其实这题不是很难. 本题可以对比P4304 [TJOI2013 ...

  2. JAVA通过URL链接获取视频文件信息(无需下载文件)

    最近项目碰到一个大坑:APP上需要在获取视频列表时就获取视频的时长,但早期上传的时候数据库都没有保存这个数据,所以前段时间添加一个时长字段,在上传时手动输入视频时长,但是之前库中有上万条数据没这个信息 ...

  3. VBox on 14.04: Kernel driver not installed (rc=-1908) [duplicate]

    这几天刚刚装上Ubuntu的系统开始写Android代码,真心是流畅了很多,但是也出现了很多的问题. 还好 有大神护佑,童鞋博客首页,点击查看吧. 刚刚又遇到了一个新的问题,那就是我想用genymot ...

  4. [leetcode] 147. Insertion Sort List (Medium)

    原题 别人的思路 非常简洁 function ListNode(val) { this.val = val; this.next = null; } /** * @param {ListNode} h ...

  5. 手动创建MySQL服务

    1.复制一份MySQL服务文件,放入一个路径 2.清理data文件夹下文件,仅保留mysql等 3.修改my.ini,port,...dir等配置 4.管理员运行cmd,cd>bin:mysql ...

  6. 微信小程序设计总结

    微信小程序是一种全新的连接用户与服务的方式,它可以在微信内被便捷地获取和传播,同时具有出色的使用体验. 小程序提供了一个简单.高效的应用开发框架和丰富的组件及API,帮助开发者在微信中开发具有原生 A ...

  7. paddlepaddle实现猫狗分类

    目录 1.预备工作 1.1 数据集准备 1.2 数据预处理 2.训练 2.1 模型 2.2 定义训练 2.3 训练 3.预测 4.参考文献 声明:这是我的个人学习笔记,大佬可以点评,指导,不喜勿喷.实 ...

  8. jsp数据交互(二).1

    对象的作用域:   JSP中提供了四种作用域,分别是page作用域,request作用域,session作用域和application作用域. page作用域: page作用域指单一JSP页面的范围, ...

  9. context创建过程解析(一)之deployDescriptors

    总结:主要是创建Context对象,并且将默认context配置,host级别配置,context配置的值设置进去,设置docBase,如果是war包就解压到webapp的目录中,重新设置docBas ...

  10. win10虚拟机搭建Hadoop集群(已完结)

    1 在虚拟机安装 Ubuntu 2 安装网络工具 Ubuntu最小化安装没有 ifconfig命令 sudo apt-get install net-tools 3 Ubuntu修改网卡名字 修改网卡 ...