spring和cxf整合
来源:互联网 发布:mysql自动增长赋值 编辑:程序博客网 时间:2024/06/10 03:44
cxf 是一个开源的服务框架。详细介绍请看官网http://cxf.apache.org/
一、配置所需jar包
整合spring 项目使用maven 进行管理。
pom中cxf部分
<span style="white-space:pre"></span><!-- cxf --><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-frontend-jaxws</artifactId><version>${cxf.version}</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-transports-http</artifactId><version>${cxf.version}</version></dependency><!-- Jetty is needed if you're are not using the CXFServlet --><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-rt-transports-http-jetty</artifactId><version>${cxf.version}</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-tools-common</artifactId><version>${cxf.version}</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-tools-java2ws</artifactId><version>${cxf.version}</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-tools-validator</artifactId><version>${cxf.version}</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-tools-wsdlto-core</artifactId><version>${cxf.version}</version></dependency><dependency><groupId>org.apache.cxf</groupId><artifactId>cxf-tools-wsdlto-databinding-jaxb</artifactId><version>${cxf.version}</version></dependency>
spring部分(此部分是手动添加的)
二、配置配置文件web.xml appliationContext.xml
web.xml中添加
<<span style="white-space:pre"></span>ontext-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
<span style="white-space:pre"><servlet><span style="white-space:pre"></span><servlet-name>CXFServlet</servlet-name><span style="white-space:pre"></span><servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class><span style="white-space:pre"></span><load-on-startup>1</load-on-startup><span style="white-space:pre"></span></servlet><span style="white-space:pre"></span><!-- CXFServlet Mapping --><span style="white-space:pre"></span><servlet-mapping><span style="white-space:pre"></span><servlet-name>CXFServlet</servlet-name><span style="white-space:pre"></span><url-pattern>/services/*</url-pattern><span style="white-space:pre"></span></servlet-mapping></span>
applicationContext.xml
注意标红位置,引用jaxws命名空间
<span style="white-space:pre"></span><beans xmlns="http://www.springframework.org/schema/beans"<span style="white-space:pre"></span>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<span style="white-space:pre"></span>xmlns:p="http://www.springframework.org/schema/p"<span style="white-space:pre"></span>xmlns:jaxws="http://cxf.apache.org/jaxws"</span><span style="white-space:pre"></span>xsi:schemaLocation="<span style="white-space:pre"></span>http://www.springframework.org/schema/beans <span style="white-space:pre"></span>http://www.springframework.org/schema/beans/spring-beans-3.0.xsd<span style="white-space:pre"></span>http://cxf.apache.org/jaxws</span> <span style="white-space:pre"></span>http://cxf.apache.org/schemas/jaxws.xsd</span>"><span style="white-space:pre"></span><import resource="classpath:META-INF/cxf/cxf.xml"/> <span style="white-space:pre"></span><import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/> <span style="white-space:pre"></span><import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <span style="white-space:pre"></span><bean id="hellobServiceImpl" class="test.impl.HelloServiceImpl"><span style="white-space:pre"></span></bean><span style="white-space:pre"></span><jaxws:server id="helloService" serviceClass="test.OrganizationWebService" address="/helloService"><jaxws:serviceBean><ref bean="helloServiceImpl"/></jaxws:serviceBean> <span style="white-space:pre"></span></jaxws:server>
三、编写服务
接口
实现
写完之后 启动tomcat,浏览器地址输入 http://localhost:8080/test/services,即可看到服务。
wsdl地址是 http://localhost:8080/test/services/helloService?wsdl
四、客户端调用
客户端调用有多种方式,请看官网。本次使用动态调用的方式,具体请看官网。
大功告成!
0 0
- cxf和spring整合
- cxf和spring整合
- spring和cxf整合
- cxf、spring和maven整合
- CXF实现和Spring整合发布WebService
- spring和cxf整合开发Webservice步骤
- CXF和spring整合实现webservice实例
- CXF和Spring MVC的整合
- CXF和spring整合实现webservice实例
- 五、CXF整合Spring
- CXF整合Spring
- CXF WebService整合Spring
- Spring 整合 CXF
- CXF整合Spring入门教程
- CXF WebService整合Spring
- CXF WebService整合Spring
- spring+cxf+bonecp整合
- CXF WebService整合Spring
- Themida和Winlicense加壳软件脱壳教程
- 【新闻发布系统】——存储过程
- 金属材料工程专业大学生个人职业生涯规划
- js 格式化时间日期函数
- (常复习)poj 1015 dp+记录dp路径+转变最优子结构+区间映射
- spring和cxf整合
- 得到包下所有类
- grep、cut常见用法
- oracle隔离级别
- Innodb独立的undo tablespace
- ADB 常用命令
- HDU 3549 Flow Problem (简单最大流问题)
- LVS群集汇总,实现高可用
- spring动态生成bean