cxf-spring-pratice-client
来源:互联网 发布:培训机构程序员 编辑:程序博客网 时间:2024/06/08 11:03
与spring集成时,客户端的相关配置.
2017/11/15 时隔六个月, 重新下组织格式和内容.
1. 引入cxf相关的依赖
1.1 使用maven
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.1.1</version></dependency><dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>3.1.1</version></dependency>
1.2 直接引入相关jar
真心不建议采用这种方式!
asm-5.0.4.jarcxf-core-3.1.1.jarcxf-rt-bindings-soap-3.1.1.jarcxf-rt-bindings-xml-3.1.1.jarcxf-rt-databinding-jaxb-3.1.1.jarcxf-rt-frontend-jaxws-3.1.1.jarcxf-rt-frontend-simple-3.1.1.jarcxf-rt-transports-http-3.1.1.jarcxf-rt-ws-addr-3.1.1.jarcxf-rt-ws-policy-3.1.1.jarcxf-rt-wsdl-3.1.1.jarjaxb-core-2.2.11.jarjaxb-impl-2.2.11.jarneethi-3.0.3.jarstax2-api-3.1.4.jarwoodstox-core-asl-4.4.1.jarwsdl4j-1.6.3.jarxml-resolver-1.2.jarxmlschema-core-2.2.1.jar
2. 创建相关类
2.1 IHelloWorld接口
与服务端完全一致的接口,建议将接口单独为一个jar.
@WebServiceinterface IHelloWorld { String sayHello(@WebParam(name = "username") String username); Map<String, Object> getObj(@WebParam(name = "username")String username, @WebParam(name = "sexy")String sexy);}
3. Spring配置
3.1 spring-cxf-client.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:context="http://www.springframework.org/schema/context" xmlns:jaxws="http://cxf.apache.org/jaxws"xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd "><!-- 官方文档: http://cxf.apache.org/docs/writing-a-service-with-spring.html *** Create a Client (More Manual Way) *** <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"> <property name="serviceClass" value="com.kq.webservice.xmlpservice"/> <property name="address" value="${webservice.service.address}/xmlpservice"/> </bean> <bean id="xmlpServiceClient" class="com.kq.webservice.xmlpservice" factory-bean="clientFactory" factory-method="create"/> --> <jaxws:client id="xmlpServiceClient" serviceClass="com.kq.webservice.xmlpservice" address="${webservice.service.address}/xmlpservice" /></beans>
3.2 spring.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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd "><!--导入上面创建的文件--><import resource="spring-cxf-client.xml"/><!--导入配置信息--><context:property-placeholder location="classpath:config/db.properties" /></beans>
4. 参考链接
- http://cxf.apache.org/docs/writing-a-service-with-spring.html - 官方文档
0 0
- cxf-spring-pratice-client
- cxf-spring-pratice-service
- spring(2) cxf client
- cxf jax-rs spring client
- cxf client
- spring cxf 进行webservice的集成(server+client)
- CXF Rest Client
- Create CXF Client
- cxf+spring
- Spring+Cxf
- cxf spring
- spring+cxf
- cxf spring
- spring cxf
- Englis Pratice
- cxf jax-rs client 笔记。
- cxf jax-rs client 笔记
- CXF生成webservice Client代码
- 结构对齐--__packed与#pragma pack
- Cannot instantiate the type HttpClient问题
- 设计的一个适合小团队小项目的git工作流
- 如何使用Hexo建立自己的Github Pages博客
- spring中的AOP
- cxf-spring-pratice-client
- Python error: Microsoft Visual C++ 9.0 is required
- FL Studio安装插件太多,容易混淆怎么办?
- 随机数进阶
- sql server 中 like 中文不匹配问题解决就这么简单
- Ext.grid.feature.Grouping页头分组如何显示其他信息
- 写给大数据开发初学者的话
- 将字符串转换成表
- 一站式linux0.11内核head.s代码段图表详解