1、依赖jar包
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.1.8</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>3.1.8</version> </dependency>
2、web.xml增加配置
<!-- apache cfx start --> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <!-- apache cfx end -->
3、applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Application context definition for PetClinic on JDBC. --> <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:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!-- apache cxf start --> <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" /> <jaxws:endpoint id="webServiceSample" address="/webServiceSample" implementor="com.zzstxx.webservice.cxf.SchoolWebServiceImpl" /> <!-- apache cxf end --> </beans>
4、接口
package com.zzstxx.webservice.cxf; import javax.jws.WebService; @WebService public interface SchoolWebService { // 测试 public String say(String hello); // 获取机构信息 public String getUnitInfo(); // 获取用户信息 public String getUserInfo(); // 获取年级、班级信息 public String getGradeClassInfo(); // 获取学生信息 public String getStudentInfo(); }
5、接口实现
package com.zzstxx.webservice.cxf; import java.util.List; import java.util.Map; @WebService(endpointInterface = "com.zzstxx.webservice.cxf.SchoolWebService") public class SchoolWebServiceImpl implements SchoolWebService { public String say(String hello) { return hello + "11"; } public String getUnitInfo() { } @Override public String getUserInfo() { } @Override public String getGradeClassInfo() { } @Override public String getStudentInfo() { } }
测试访问地址:
http://127.0.0.1:8080/services/webServiceSample?wsdl
相关推荐
CXF集成Spring发布WebService代码实例
Cxf集成Spring的WebService接口的配置文档
cxf集成Spring的restful WebServ ice接口,Demo的完整代码!
自己总结的一个CXF集成Spring的例子,可以直接运行,附源码! 程序的详细说明请参照博客文档 http://blog.csdn.net/sunbaojin5213344/article/details/8931600
cxf集成Spring的restful WebService接口以Json形式表现的完整代码,适合新入门在学WebService的小伙伴们参考,希望对你们有帮助!
将cxf集成到spring中。用到的工具eclipse3.3 maven2
自己在用的接口框架,实现了CXF和spring和hibernate的集成
apache-cxf集成springMVC所需的cxf基本包 测试没问题
绝对可运行,里面有客户端和服务端还有对应的操作文档,导入eclipse或者MyEclipse十分钟内就搞定,虽然贵点但是绝对物有所值.
这个是cxf 集成spring 的webservice的例子 供大家参考
cxf与spring集成 需要最少的jar如下: cxf-2.3.3.jar geronimo-annotation_1.0_spec-1.1.1.jar geronimo-jaxws_2.2_spec-1.0.jar geronimo-stax-api_1.0_spec-1.0.1.jar geronimo-ws-metadata_2.0_spec-1.1.3.jar ...
Apache cxf 与spring集成
cxf集成Spring的服务器段的例子 由于上传50M的限制 客户端是单独上传的
CXF 集成 mybatis spring 环境搭建,以及开发所需要的CXF JAR 包
cxf+spring+hibernate集成整合jar包
详细介绍Cxf集成与Spring 实现WebService.
spring struts cxf 集成
使用最新的CXF2.7和Spring3的 Java WebService 集成用例 应用Spring Annotation