apache cxf笔记之Spring客户端访问和调用webservice服务
继续上次的spring服务的问题,这边介绍一种spring配置客户端的方法。
1、src目录下新建client-beans.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<!-- 方式一:基于spring的jaxws -->
<!-- <jaxws:client
id="client" serviceClass="demo.cxf.helloworld.HelloWorld"
address="http://localhost:8080/HelloWorld"/> -->
<!-- 方式二:基于cxf的JaxWsProxyFactoryBean -->
<bean id="client" class="demo.cxf.helloworld.client.ClientSpring"
factory-method="create" factory-bean="clientFactory"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="demo.cxf.helloworld.HelloWorld"/>
<property name="address" value="http://localhost:8080/HelloWorld"/>
</bean>
</beans>
2、客户端调用类:ClientSpring
package demo.cxf.helloworld.client;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import demo.cxf.helloworld.HelloWorld;
public class ClientSpring {
public static void main(String[] args) {
System.out.println("Start client.....");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath:client-beans.xml" });
HelloWorld helloWorld = (HelloWorld) context.getBean("client");
System.out.println(helloWorld.sayHello("Jobs"));
System.exit(0);
}
}
3、先启动前面所讲的spring服务
4、运行客户端程序Run as JavaApplication
其实还有代码直接实现的,不用配置文件的,这边就不介绍了,跟配置文件类似的。实际开发中还是主要用到XML配置文件的。
apache cxf笔记之Spring客户端访问和调用webservice服务的更多相关文章
- Spring Boot 使用 JAX-WS 调用 WebService 服务
除了 CXF 我们还可以使用 Spring Boot 自身默认的组件 JAX-WS 来实现 WebService 的调用. 本项目源码 github 下载 1 新建 Spring Boot Maven ...
- Spring Boot 使用 CXF 调用 WebService 服务
上一张我们讲到 Spring Boot 开发 WebService 服务,本章研究基于 CXF 调用 WebService.另外本来想写一篇 xfire 作为 client 端来调用 webservi ...
- cxf 调用 webservice服务时传递 服务器验证需要的用户名密码
cxf通过wsdl2java生成客户端调用webservice时,如果服务器端需要通过用户名和密码验证,则客户端必须传递验证所必须的用户名和密码,刚开始想通过url传递用户名和密码,于是在wsdl文件 ...
- winform客户端程序第一次调用webservice方法很慢的解决方法
.net2.0的winform客户端最常用的与服务端通信方式是通过webservice,最近在用dottrace对客户端做性能测试的时候发现,客户端程序启动以后,第一次调用某一个webservice的 ...
- C#开发WEBService服务 C++开发客户端调用WEBService服务
编写WEBService服务端应用程序并部署 http://blog.csdn.net/u011835515/article/details/47615425 编写调用WEBService的C++客户 ...
- Apache cxf暴露接口以及客户端调用之WebService初步理解
在我们真实的项目中,经常会调用别人提供给我们的接口,或者在自己的团队中, restful风格的前后端分离也经常会提供一个后端接口暴露出去供app,或者.net/C/C++程序员去调用,此时就需要使用到 ...
- C++客户端通过gSOAP调用WebService
webService三要素: SOAP(Simple Object Access Protocol).WSDL(WebServicesDescriptionLanguage).UDDI(Univers ...
- Spring与apache CXF结合实例
本文的前提是已经有一个Spring的项目,在此基础上如何跟apache CXF进行结合,开发出WebService服务和调用WebService服务. 1.开发WebService 1.引入jar ...
- 基于Apache CXF的Web Service服务端/客户端
转自:https://www.aliyun.com/zixun/wenji/1263190.html CXF服务端: package com.sean.server; import javax.jws ...
随机推荐
- cocos2d-x 3.0 rapidJson 解析操作应该注意的细节
Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstanc ...
- C#中使用REDIS
C#中使用REDIS 上一篇>> 摘要 上一篇讲述了安装redis客户端和服务器端,也大体地介绍了一下redis.本篇着重讲解.NET4.0 和 .NET4.5中如何使用redis和C# ...
- Node+Express+MongoDB + Socket.io搭建实时聊天应用
Node+Express+MongoDB + Socket.io搭建实时聊天应用 前言 本来开始写博客的时候只是想写一下关于MongoDB的使用总结的,后来觉得还不如干脆写一个node项目实战教程实战 ...
- Oracle 11g for Windows 简体中文版的安装过程
原文:Oracle 11g for Windows 简体中文版的安装过程 我的配置 操作系统:Windows Server 2003 sp2 内存:1024M以上 1.下载Oracle 11g 地址 ...
- Ajax.ActionLink 用法
Ajax.ActionLink 用法 Ajax 属性的ActionLink方法可以创建一个具有异步行为的锚标签. ActionLink方法的第一个参数指定了链接文本,第二个参数是要异步调用的操作的名称 ...
- mcstructs-MircoCStructs用C语言实现的微型数据结构库
以C语言的方式,我将逐步实现以下算法: 我的Github地址为:https://github.com/tfa2012/mcstructs 1 线性链表 2 环形缓冲区 3 Hash表
- POJ 2560 Freckles Prime问题解决算法
这个问题正在寻求最小生成树. 给定节点的坐标,那么我们需要根据各个点之间的这些坐标来计算距离. 除了这是标准的Prime算法的,能源利用Prime基本上,你可以使用Kruskal. 经典的算法必须填写 ...
- js 拖拽实现
代码参考 <!DOCTYPE html> <html lang="en"> <title>拖拽</title> <head&g ...
- ubuntu下的词典的安装
因为从事开发,安装一个词典是很有必要,文中介绍安装openyoudao和stardic两个软件的方法 一.openyoudao的安装 因为是由window转来学ubuntu的,所以总是想安装和wind ...
- 架构师Jack专访:全面认识软件测试架构师
◇ 测试架构师的职责 测试的职业通道基本是管理线和技术线两条路. 管理线主要的职责:更多是项目管理和资源管理. 技术线主要的职责:更多是技术管理和业务知识. 软件测试架构师更多就是技术线的带头人.管理 ...