该教程使用的项目可参见:

Intellij Idea下搭建基于Spring+SpringMvc+MyBatis的WebApi接口架构

具体源码请参见GitHub:

https://github.com/chenyangsocool/ssm.git

1.在maven的pom文件中添加cxf版本属性信息:

<cxf.version>3.0.8</cxf.version>

添加如下cxf的jar包:

<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>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
<version>1.1.3</version>
</dependency>

2.在ITestService上添加@WebService标签,最后文件如下:

package com.chenyangsocool.ssm.service;

import com.chenyangsocool.ssm.model.Test;

import javax.jws.WebService;

@WebService
public interface ITestService {
public Test getModelById(int id);
}

3.在resources目录下新建spring-cxf.xml文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!-- START SNIPPET: beans -->
<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-servlet.xml"/>
<jaxws:endpoint id="TestService" implementor="com.chenyangsocool.ssm.service.impl.TestServiceImpl" address="/TestService"/>
</beans>

4.在web.xml的<context-param>中添加spring-cxf.xml,最后如下:

    <param-value>
classpath:spring-mybatis.xml
classpath:spring-cxf.xml
</param-value>

再添加:

  <servlet>
<description>Apache CXF Endpoint</description>
<display-name>cxf</display-name>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>

OK,到此结束,运行你的项目,输入:http://localhost:8080/ssm/webservice

里面就有你添加的服务:TestService:

http://localhost:8080/ssm/webservice/TestService?wsdl

本项目GitHub地址:https://github.com/chenyangsocool/ssm.git

参考(这一篇基本上是照搬了,感谢原作者):

spring4.1.6+cxf3.0.8的简单WebService案例(maven工程)

spring 4.0下集成webservice的更多相关文章

  1. spring boot2.0.4集成druid,用jmeter并发测试工具调用接口,druid查看监控的结果

    一.项目介绍(本项目用的编程语言是jdk8,项目源码:https://github.com/zhzhair/spring-boot-druid.git) 1.引入pom依赖: <dependen ...

  2. Ubuntu18.04和OpenWrt 18.06.0 下使用aria2和BaiduExport处理百度盘下载

    Ubuntu下没有可用的百度盘客户端, 下载大文件如果通过浏览器就会特别不可靠. 可以使用Chrome插件 BaiduExport 得到下载链接和参数后, 通过aria2进行下载. Aria2安装 直 ...

  3. spring 3.0系统集成webservice

    spring 3.0系统集成webservice,踩了很多坑以后总算成功了,故写下这篇博客以记录. 1.准备jar包 由于项目是spring3.0,所以应该要使用cxf 2.7版本才可以成功配置,高版 ...

  4. java web项目(spring项目)中集成webservice ,实现对外开放接口

    什么是WebService?webService小示例 点此了解 下面进入正题: Javaweb项目(spring项目)中集成webservice ,实现对外开放接口步骤: 准备: 采用与spring ...

  5. 在Spring下集成ActiveMQ

    1.参考文献 Spring集成ActiveMQ配置 Spring JMS异步发收消息 ActiveMQ 2.环境 在前面的一篇ActiveMQ入门实例中我们实现了消息的异步传送,这篇博文将如何在spr ...

  6. tomcat 7下spring 4.x mvc集成websocket以及sockjs完全参考指南

    之所以sockjs会存在,说得不好听点,就是因为微软是个流氓,现在使用windows 7的系统仍然有近半,而windows 7默认自带的是ie 8,有些会自动更新到ie 9,但是大部分非IT用户其实都 ...

  7. 在spring环境下集成ActiveMQ

    1.参考文献 Spring集成ActiveMQ配置 Spring JMS异步发收消息 ActiveMQ 2.环境 在前面的一篇ActiveMQ入门实例中我们实现了消息的异步传送,这篇博文将如何在spr ...

  8. tomcat 7下spring 4.x mvc集成websocket以及sockjs完全参考指南(含nginx/https支持)

    之所以sockjs会存在,说得不好听点,就是因为微软是个流氓,现在使用windows 7的系统仍然有近半,而windows 7默认自带的是ie 8,有些会自动更新到ie 9,但是大部分非IT用户其实都 ...

  9. 在spring+springMvc+mabatis框架下集成swagger

    我是在ssm框架下集成swagger的,具体的ssm搭建可以看这篇博文: Intellij Idea下搭建基于Spring+SpringMvc+MyBatis的WebApi接口架构 本项目的GitHu ...

随机推荐

  1. Search a 2D Matrix leetcode java

    题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the f ...

  2. 让两个DIV的高度隐式同步

    以前遇到两个相临近的块,高度要一样,但是内容多少又不定时,我都是通过把这两块封装在TD里面实现,但今天在CSDN上面看到有人要通过JS来实现这个,我尝试了一下.http://topic.csdn.ne ...

  3. vue-router路由知识补充

    1.render函数 var app = new Vue({ el: '#app', router, render: h => h(App) //新添加的函数操作 }) 我们新加了render: ...

  4. 微信小程序开发:设置消息推送

    开发设置中,启用并设置消息推送配置后,用户发给小程序的消息以及开发者需要的事件推送,都将被微信转发至该服务器地址中. 不过照着说明去操作,即使按照最简单的明文方式去设置,还是提示Token验证失败.仔 ...

  5. 浅谈Java两种并发类型——计算密集型与IO密集型

    转载:https://blog.csdn.net/u013070853/article/details/49304099 核心是可以分别独立运行程序指令的计算单元.线程是操作系统能够进行运算调度的最小 ...

  6. 日媒:阿里巴巴上市融资或超Facebook

    <日本经济新闻>4月22日报导称, 越来越多观念以为,正准备在美国股票商场上市的阿里巴巴集团的融资额将超越美国Facebook.假如完毕,作为互联网公司将创出融资额的历史新高.阿里巴巴现已 ...

  7. Opencv2.4.9安装和在visualstudio 2013中配置

    Opencv2.4.9安装和在visualstudio 2013中配置 下载opencv和在windows下安装: 最新版本号的opencv是2014.4.25的opencv2.4.9,这里选择当前最 ...

  8. Android Developers:日历提供者

    <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="ht ...

  9. poj 1879 Truck History

    本题链接:点击打开链接 题目大意: 输入n表示卡车辆数,输入每辆卡车编号.即长度为7的字符串,每辆卡车编号均可由其他类型编号衍生过来,求由当中一辆衍生出其他全部的最小衍生次数(有一个字符不同就需衍生一 ...

  10. Performance Testing

    To test application performance, add rules using FiddlerScript to the OnBeforeResponse function (exc ...