apache cxf笔记之Spring客户端访问和调用webservice服务
来源:互联网 发布:天谕豪男捏脸数据 编辑:程序博客网 时间:2024/06/12 19:04
继续上次的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整合cxf发布webservice服务和spring boot整合cxf客户端调用webservice服务
- spring boot整合cxf发布webservice服务和cxf客户端调用
- spring boot整合cxf发布webservice服务和cxf客户端调用
- CXF----webservice和Spring之JaxWsProxyFactoryBean调用
- webservice学习之使用Apache CXF和spring搭建webservice
- cxf+spring发布webservice服务(客户端)
- cxfspring boot整合cxf发布webservice服务和cxf客户端调用
- CXF 客户端 远程调用WebService(笔记)
- apache cxf笔记之利用spring创建服务程序
- Spring整合CXF之发布WebService服务
- Spring整合CXF之发布WebService服务
- Spring整合CXF之发布WebService服务
- Spring整合CXF之发布WebService服务
- 使用CXF和spring搭建webService服务
- WebService学习笔记:使用CXF+Spring搭建WebService服务端和客户端
- CXF 服务调用之java客户端代码
- cxf+spring发布webservice和调用
- 转:谷歌内幕:详解互联网巨头的做事逻辑
- Ant编译android程序
- SQLSERVER2000与SQLSERVER2005的配置分析需要
- linux 中$1什么意思
- 排序 - 交换排序 [3 -- 快速排序,中间元素为支点]
- apache cxf笔记之Spring客户端访问和调用webservice服务
- 尝试解决ubuntu12.10无线联网不定时死机问题
- 韩信点兵
- 10801 - Lift Hopping
- Hibernate与Ibatis(Mybatis)
- 求2个数的最大公约数
- Python学习 - 1
- (a)ttempt SQL Ping and Auto Quick Brute Force 续2——原因
- 解决source命令导入 带utf-8字符的.sql 产生乱码的问题