CXF 在Spring中开发服务端步骤
2013-10-10 17:37
141 查看
1,导入jar 包
2.写接口
3.写实现类
4.配置spring-ws.xml
<!-- cxf --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-api</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-bindings-soap</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-ws-security</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.3</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore-nio</artifactId> <version>4.3</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpasyncclient</artifactId> <version>4.0-beta4</version> </dependency> <!-- cxf -->
2.写接口
package com.sharp.hibernatedemo.ws; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import com.sharp.hibernatedemo.domain.User; @WebService @SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL) public interface IUserServiceWs { void addUser(User user); }
3.写实现类
package com.sharp.hibernatedemo.ws.impl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.sharp.hibernatedemo.domain.User; import com.sharp.hibernatedemo.service.IUserService; import com.sharp.hibernatedemo.ws.IUserServiceWs; @Component("userServiceWs") public class UserServiceWsImpl implements IUserServiceWs { @Autowired private IUserService userService; public void addUser(User user) { userService.addUser(user); } }
4.配置spring-ws.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:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.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-servlet.xml" /> <jaxws:server id="userServiceWss" serviceClass="com.sharp.hibernatedemo.ws.IUserServiceWs" address="/userServiceWs"> <jaxws:serviceBean> <ref bean="userServiceWs" /> <!-- 和上面的id名字一定不要重复了 --> </jaxws:serviceBean> </jaxws:server> </beans>
相关文章推荐
- spring和cxf整合开发Webservice步骤
- CXF 开发RESTful WebService服务(Spring+JPA服务端,JAXRS2.0+WebClient客户端)
- 使用CXF开发WebService程序的总结(七):Spring+CXF+Mybatis+Mysql共同打造的服务端示例
- WebService学习总结(四)——使用spring+CXF开发WebService(服务端)
- spring集成CXF服务端
- Spring+MyBatis项目开发代码步骤
- 使用Spring+CXF开发WebService,使用注解方式
- Webservice的cxf开发_使用spring发布服务+ajax调用服务
- Spring + JDBC 组合开发集成步骤
- webService(CXF开发SOAP应用,CXF整合spring)未完待续
- CXF创建webservice服务端、客户端,与spring集成
- Struts + Spring +ibatis 整合开发步骤
- spring + cxf 的webservice服务端和客户端功能
- CXF开发webservice需要的最少jar包以及CXF 和 Spring集成所需jar包
- CXF使用教程(三)——基于Spring的webService开发
- Apache CXF+Spring开发环境搭建小试
- webservice 服务端例子+客户端例子+CXF整合spring服务端测试+生成wsdl文件 +cxf客户端代码自动生成
- Hibernate+Spring整合开发步骤
- 基于JAX-WS的Web Service服务端/客户端 ;JAX-WS + Spring 开发webservice
- webservice开发三:CXF+Spring开发WebService