前提:

  1.spring mvc环境已搭建好,能跑起来。

  2.下载apache-cxf-2.7.3.zip的压缩包,解压apache-cxf-2.7.3.zip压缩包,拷贝如下几个jar包即可。

  

配置web.xml文件:

  <context-param>    
      <param-name>contextConfigLocation</param-name>    
      <param-value>classpath:applicationContext.xml,classpath:cxf-services.xml</param-value>
   </context-param>

  <servlet>
       <servlet-name>CXFServlet</servlet-name>
       <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
   <load-on-startup>2</load-on-startup>
   </servlet>
   <servlet-mapping>
       <servlet-name>CXFServlet</servlet-name>
      <url-pattern>/services/*</url-pattern>
   </servlet-mapping>

java代码:

  Service接口类:

  import javax.jws.WebService;

  @WebService
  public interface CxfService {
     public String sayHello(String username);
  }

  Service接口实现类:

  import javax.jws.WebService;

  @WebService(endpointInterface = "com.digitalchina.xcf.dao.CxfService", serviceName = "helloWorld", targetNamespace = "http://dao.cxf.ws.com/")
  public class CxfServiceImpl {

    public String sayHello(String username) {
        return username + "hello world";
     }

  }

配置cxf-services.xml文件:

  开头需要引入以下三个文件:

  <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 implementor表示要 暴露的bean,address表示wsdl的访问路径-->
   <jaxws:endpoint id="helloWorld" implementor="com.digitalchina.xcf.dao.impl.CxfServiceImpl" address="/HelloWorld" />

页面访问路径:http://localhost:7002/card/services/HelloWorld?wsdl,如果能看到xml信息就说明配置成功了。

Spring MVC和CXF集成的更多相关文章

  1. Spring MVC 学习总结(十)——Spring+Spring MVC+MyBatis框架集成(IntelliJ IDEA SSM集成)

    与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC负责请求的转发和 ...

  2. Spring MVC 学习总结(六)——Spring+Spring MVC+MyBatis框架集成

    与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC负责请求的转发和 ...

  3. Spring+Spring MVC+MyBatis框架集成

    目录 一.新建一个基于Maven的Web项目 二.创建数据库与表 三.添加依赖包 四.新建POJO实体层 五.新建MyBatis SQL映射层 六.JUnit测试数据访问 七.完成Spring整合My ...

  4. spring mvc+mybatis+maven集成tkmapper+pagehelper

    <!-- maven tkmapper引入--> <dependency> <groupId>tk.mybatis</groupId> <arti ...

  5. Spring MVC 中急速集成 Shiro 实践

    相信有很多的程序员,不愿意进行用户管理这块代码实现. 原因之一,不同的JavaEE 系统,用户管理都会有个性化的实现,逻辑很繁琐. 而且是系统门面,以后背锅的几率非常大,可谓是低收益高风险. 最近在系 ...

  6. (通用Mapper、分页,批量插入,一分钟接入)spring mvc+mybatis+maven集成tkmapper+pagehelper

    <!-- maven tkmapper引入--> <dependency> <groupId>tk.mybatis</groupId> <arti ...

  7. mybatis实战教程(mybatis in action)之六:与Spring MVC 的集成

    前面几篇文章已经讲到了mybatis与spring 的集成.但这个时候,所有的工程还不是web工程,虽然我一直是创建的web 工程.今天将直接用mybatis与Spring mvc 的方式集成起来,源 ...

  8. Spring MVC 学习总结(十一)——IDEA+Maven+多模块实现SSM框架集成

    一.SSM概要 与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC ...

  9. mybatis :与Spring MVC 的集成

    用mybatis与Spring mvc 的方式集成起来,源码在本文结尾处下载.主要有以下几个方面的配置1. web.xml 配置 spring dispatchservlet ,比如为:mvc-dis ...

随机推荐

  1. Shell_2 语句

    1 if else fi if 语句通过关系运算符判断表达式的真假来决定执行哪个分支.Shell 有三种 if ... else 语句: if ... fi 语句: if ... else ... f ...

  2. 返水bug-霸世

    NOOK(N) CSBFB(25) off(Y) QQ(2652880032) G(1) off1(Y) QQ1(3479301404) G1(1) off2(Y) QQ2(309235846) G2 ...

  3. Anaular指令详解

    目录:directive()   restrict   replace   template   templateUrl  scope  transclude   ng-transclude   co ...

  4. Linux Shell 流程控制语句

    * 本文主要介绍一些Linux Shell 常用的流程控制语句* 1. if 条件语句:if-then/if-elif-fi/if- else-fi if [条件判断逻辑1];then command ...

  5. Junit测试框架 Tips

    关于Junit测试框架使用的几点总结: 1.Junit中的测试注解: @Test →每个测试方法前都需要添加该注解,这样才能使你的测试方法交给Junit去执行. @Before →在每个测试方法执行前 ...

  6. 【Linux】crontab 定时任务

    7月份,公司海外运营国发生数据库联接未释放,造成连接池连接不足的情况, 当时查询并没有及时解决问题, 为了避免现场同事多次人工重启系统的,因此写了个shell脚本,通过crontab 实现系统重启,但 ...

  7. CSS3属性transform详解之(旋转:rotate,缩放:scale,倾斜:skew,移动:translate)

    CSS3属性transform详解之(旋转:rotate,缩放:scale,倾斜:skew,移动:translate)   在CSS3中,可以利用transform功能来实现文字或图像的旋转.缩放.倾 ...

  8. Windows下使用doxygen阅读和分析C/C++代码

    Windows下使用doxygen阅读和分析C/C++代码 转自:http://blog.sina.com.cn/s/blog_63d902570100gwk6.html 虽然使用各种IDE或者Sou ...

  9. web常见错误提示总结

    在写web程序的时候,经常会出现一些网页错误的数字提示,如果能够明白这些提示的含义,那对于调试程序是有极大帮助的.网上有很多这方面的总结,但为了适应自己的阅读习惯,以及日后的查找方便,就做了一些修改并 ...

  10. MySQL表名和数据库关键字相同解决办法

    今天改他们的代码的时候,遇到了MySQL表名和数据库关键字的问题. 由于表名是关键字,导致增删改查都报错. Hibernate: select leave0_.id as id22_, leave0_ ...