在Spring中调用基于CXF框架的webService
来源:互联网 发布:网络药店排名 编辑:程序博客网 时间:2024/05/22 09:42
1.添加CXF相关的依赖
<dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-frontend-jaxws</artifactId><version>2.6.1</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-transports-common</artifactId><version>2.5.4</version><type>jar</type><scope>compile</scope></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-core</artifactId><version>2.6.1</version><type>jar</type><scope>compile</scope></dependency>
2.下载apache-cxf-2.6.2.zip文件,解压,在cmd命令下,进入../apache-cxf-2.6.2/bin 目录.输入命令,如下图:
-d . 代表生成的文件输出目录, . 代表当前目录(注意有个点),-p com.xmg.cxf 表示生成的文件是按com.xmg.cxf 目录存放的.最后一个参数就是wsdl地址
生成的文件如下:
ICalculateService.java保留,其他文件都可以删除.然后放入项目中.
注意:把ICalculateService.java里面 @XmlSeeAlso({ObjectFactory.class})这行代码删掉
3.在application.xml中配置这个服务调用对象
<bean id="subFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"><property name="serviceClass" value="com.xmg.cxfspring.ICalculateService" /><property name="address"value="http://localhost/ws/calculateService?wsdl" /></bean><bean id="subService" class="com.xmg.cxfspring.ICalculateService"factory-bean="subFactory" factory-method="create" />
4.在Controller或者需要调用的地方注入subService的这个bean就可以了.
package cn.xmg.crm.controller;import javax.annotation.Resource;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import com.xmg.cxfspring.ICalculateService;@Controllerpublic class TestController {@Resource(name="subService")private ICalculateService service;@RequestMapping("testservice")public void test(){System.out.println(service.add(5, 7));}}
基于maven在spring中配置CXF:http://blog.csdn.net/qq3516744991/article/details/50834384
0 0
- 在Spring中调用基于CXF框架的webService
- 在spring中集成webservice 框架 CXF
- spring中发布基于cxf的webservice
- 基于CXF框架的WebService
- 在 Spring中集成CXF--->演示webservice服务的发布及调用
- 基于Maven在Spring中集成CXF Web Service框架
- 基于Maven在Spring中集成CXF框架
- Android调用基于cxf的WebService接口
- webservice 基于spring的cxf发布
- WebService的CXF框架整合Spring
- 基于JAX-WS的WebService在Spring框架中的实现与调用
- WebService-CXF-Spring基于web的cxf
- java调用基于SOAP的CXF 框架的WebService客户端和服务器段helloworld例子
- 基于Maven环境进行Spring集成CXF WebService框架
- WebService学习笔记-使用CXF编写基于Spring的Webservice
- CXF+Spring发布WebService 以及 对WebService的调用
- 基于Spring+CXF技术开发WebService
- CXF 创建 WebService (基于 Spring)
- MySQL之Alter语句用法总结
- 智能指针(二):shared_ptr实现原理
- PHP变量
- 智能指针(三):unique_ptr使用简介
- 20160309,微软3月8日发布13个安全补丁
- 在Spring中调用基于CXF框架的webService
- 设计模式(九)外观模式Facade(结构型)
- java枚举使用详解
- iOS证书描述文件说明
- Remove Linked List Elements
- Android最佳实践 —— 详细谈谈如何减小APK体积
- Ubuntu下 嵌入式Qt开发环境的搭建--转载
- C++面向对象高级编程笔记02--GeekBand
- 使用Jmeter进行Web站点性能测试实例