在spring中集成webservice 框架 CXF
1.在eclipse下新建个web项目(我比较喜欢用eclipse),接着添加CXF必须依赖的jar包
commons-logging-1.1.jar
geronimo-activation_1.1_spec-1.0-M1.jar (or Sun's Activation jar)
geronimo-annotation_1.0_spec-1.1.jar (JSR 250)
geronimo-javamail_1.4_spec-1.0-M1.jar (or Sun's JavaMail jar)
geronimo-servlet_2.5_spec-1.1-M1.jar (or Sun's Servlet jar)
geronimo-ws-metadata_2.0_spec-1.1.1.jar (JSR 181)
jaxb-api-2.0.jar
jaxb-impl-2.0.5.jar
jaxws-api-2.0.jar
neethi-2.0.jar
saaj-api-1.3.jar
saaj-impl-1.3.jar
stax-api-1.0.1.jar
wsdl4j-1.6.1.jar
wstx-asl-3.2.1.jar
XmlSchema-1.2.jar
xml-resolver-1.2.jar
2.添加spring jar包
aopalliance-1.0.jar
spring-core-2.0.4.jar
spring-beans-2.0.4.jar
spring-context-2.0.4.jar
spring-web-2.0.4.jar
3.构建webservice 本例子是基于jdk1.5 或者更高的版本 通过注解来构建webservice
webservice的接口
package demo.spring;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
String sayHi(String text);
}
webservice 的接口实现
package demo.spring;
import javax.jws.WebService;
@WebService(endpointInterface = "demo.spring.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
public String sayHi(String text) {
return "Hello " + text;
}
}
4 。 spring bean的配置文件
bean.xml
<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">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="hello" class="demo.spring.HelloWorldImpl" />
<jaxws:endpoint id="helloWorld" implementor="#hello" address="/HelloWorld" />
<!-- 另一种写法 是
<jaxws:endpoint id="helloWorld" implementor="demo.spring.HelloWorldImpl" address="/HelloWorld" />
在这里我建议不要用这种方法 ,如果实现类有的属性要通过spring依赖注入的话,这种方法只是简单的new个实现类,他的属性没有通过spring依赖注入给注入值
所有综合考虑 建议使用上面的写法!
-->
</beans>
5. web.xml加载bean.xml文件
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/beans.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
6.创建客户端配置文件
client-bean.xml
<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-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
<bean id="client" class="demo.spring.HelloWorld"
factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="demo.spring.HelloWorld"/>
<property name="address" value="http://localhost:8080/HelloWorld"/>
</bean>
</beans>
7.客户端访问
ApplicationContext context = ...; // your Spring ApplicationContext
HellWorld client = (HelloWorld) context.getBean("client");
OK 。。。其实就是这样的哦。。。。
转载于:https://www.cnblogs.com/chenying99/archive/2012/11/21/2781010.html
在spring中集成webservice 框架 CXF相关推荐
- 在安卓系统中集成YAHFA框架
本次尝试在Android-9.0.0_r10中集成Hook框架 - 创建hook服务进行hook配置的管理 创建接口文件 /frameworks/base/core/java/android/app/ ...
- spring中集成lettuce
lettuce是redis连接池未来的发展趋势,在spring中集成lettuce需要引入两个依赖,lettuce和spring-data-redis,引入是注意版本的关系,根据maven中央仓库的版 ...
- 【WebService框架-CXF】——WebService和CXF
在接下来的几篇博客中将对CXF的基础知识和简单应用进行总结.下面列出了要总结的内容.本篇文章集中介绍CXF的基础知识. CXF博客总结目录 WebService和CXF基础知识 CXF入门实例(编写客 ...
- Spring中集成ActiveRecordPlugin数据操作插件
2019独角兽企业重金招聘Python工程师标准>>> ###Spring集成ActiveRecordPlugin数据操作插件 package com.yunhetong.mq.se ...
- spring boot集成webservice接口
依赖集成 当前spring boot 版本是 2.0.1.RELEASE, 其对应的cxf依赖版本为:3.2.4, 详情如下: <dependency><groupId>org ...
- Spring Boot 集成 批处理框架Spring batch
Spring Batch是一个轻量级的框架,完全面向Spring的批处理框架,用于企业级大量的数据读写处理系统.以POJO和Spring 框架为基础,包括日志记录/跟踪,事务管理. 作业处理统计工作重 ...
- spring Boot 2 运维篇(spring boot程序的打包与部署,多环境开发配置文件的配置,spring boot集成日志框架)
目录 1.SpringBoot程序的打包与运行 程序打包 程序运行 SpringBoot程序打包失败处理 命令行启动常见问题及解决方案 SpringBoot项目快速启动(Linux版) 2.配置高级 ...
- MyBatis延迟加载及在spring中集成配置
当你要使用one to one,many to one 就会碰到N+1的问题.很明显,对象之间关联很多有A关联B,B关联C,C关联A这样的关系,如果不是采用延迟加载,很容易一下在出现成千上万对象 ...
- spring中集成使用jedis(2)
本文主要就spring注入的连接池使用问题,做简要说明. 使用过JedisPool的同学会发现,通过JedisPool获取资源,在使用完毕后,需要显式的将资源放回连接池中, 如下: JedisPool ...
最新文章
- Windows 8 Metro App学习笔记(九)—磁砖
- java队列研究_辨证论治失眠疗效评价的医生队列研究
- [YTU]_2570 指针练习——变量交换
- Redis数据库(四)——Redis集群模式(主从复制、哨兵、Cluster)
- 从零开始实现multipart/form-data数据提交
- LeetCode 154 寻找旋转排序数组中的最小值 II
- SqlServer为什么自动在主键上建立聚集索引
- 第 72 章 FAQ
- mac安装ffmpeg
- 2017.3.18 PPT汇报--总结
- WEBPACK+ES6+REACT入门(2/7)-在项目中使用react以及JSX语法介绍
- 通用权限管理概要设计说明书
- SQL 删除数据空格(Trim、RTrim、LTrim函数)
- (附源码)node.js游云旅游网站 毕业设计 231547
- ASP.Net三层架构
- Instagram移动网页版推图片分享功能:追求国际增长
- excel单个对象用poi导出,并设置每个sheet得最大行数防止报错
- 办公小技巧,批量修改文件名,手把手教你
- 孩子学习arduino好还是单片机好
- 他是阿里顶尖科学家,扛起国产分布式数据库大旗,性能超Oralce 20倍!
热门文章
- Visual Entity 下载列表(最新版为 2.0.0 ,已支持Visual Studio 2013)
- 微软开发中心的rss历史记录(24)
- button点击改变颜色_【干货】眉笔颜色要选对,三步教你选择正确眉色
- C++实现有哨兵的双向循环链表
- 垃圾邮件过滤 php,垃圾邮件过滤功能
- 网络爬虫--SAX处理xml
- Flutter GitHub Travis CI 搭建
- linux环境搭建seafile客户端自动上传文件
- Lync Server 2013 标准版部署(二)DNS记录权限
- java ASM 分析类