webservice的cxf和spring整合客户端开发
2024-09-04 09:48:27
1、新建一个java项目
2、导入cxf相关的jar包,并部署到项目中
3、用命令生成客户端使用说明文档
wsdl2java -p com.xiaostudy -d . http://127.0.0.1:8080/demo12/ws/number?wsdl
4、编写applicationContext.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"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<jaxws:client id="client" address="http://127.0.0.1:8080/demo12/ws/number" serviceClass="com.xiaostudy.TestServiceImpl"/>
</beans>
5、开启客户端
package com.xiaostudy; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; /**
* @desc 客户端
* @author xiaostudy
*
*/
public class MyClient { public static void main(String[] args) { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
TestServiceImpl testServiceImpl = (TestServiceImpl)applicationContext.getBean("client");
System.out.println(testServiceImpl);
String string = testServiceImpl.getNumber("666");
System.out.println(string);
} }
6、运行客户端,看是否成功
最新文章
- mysql源码包手动安装、配置以及测试(亲测可行)
- 敏捷开发XP
- C#加密解密(DES,AES,Base64,md5,SHA256,RSA,RC4)
- MVVM了解
- Android 5中不同效果的Toast
- android button minheight问题
- 零售业数据分析的媒介——BI工具
- nat模式、路由模式,网桥模式
- 不熟悉的CSS样式
- Storm流计算从入门到精通之技术篇(高并发策略、批处理事务、Trident精解、运维监控、企业场景)
- sodu 命令场景分析
- tomcat中的线程问题2
- 【国庆】记一次mysqld_safe引发mysql进程故障
- golang实现的简单优先队列
- C++版 - 剑指offer 面试题5:从尾到头打印链表 题解
- META-INF文件夹中的MANIFEST.MF 的作用
- 学习笔记之PostgreSQL / pgAdmin / Psycopg / PostGIS
- 请求(Request)的参数(Param)里包含特殊字符(#等)的正确处理方式
- JETTY+NGINX
- ubuntu 14.04 安装 gflags