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

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. UVA 10474 (13.08.04)

     Where is the Marble?  Raju and Meena love to play with Marbles. They have got a lotof marbles with ...

  2. go语言基础之复合类型

    1.分类 类型 名称 长度 默认值 说明 pointer 指针 nil array 数组 0 slice 切片 nil 引⽤类型 map 字典 nil 引⽤类型 struct 结构体 2.指针 指针是 ...

  3. Partition List leetcode java

    题目: Given a linked list and a value x, partition it such that all nodes less than x come before node ...

  4. Java基础(一):简介

    一.java基础语法: 一个Java程序可以认为是一系列对象的集合,而这些对象通过调用彼此的方法来协同工作.下面简要介绍下类.对象.方法和实例变量的概念. 对象:对象是类的一个实例,有状态和行为.例如 ...

  5. 查询分页-----强势top

    查询分页:语句1性能提升10倍多,仅仅是由于多了个topkeyword,非常不理解啊!!!! 1.查询时间1s内,r_object_id主键 select top 100 * from (  sele ...

  6. Go常用功能总结一阶段

    1. go语言从键盘获取输入内容 <1. 最简单的办法是使用 fmt 包提供的 Scan 和 Sscan 开头的函数.请看以下程序: package main import "fmt& ...

  7. 安装Oracle之后解决掉的问题分享

    TNS-03505: 无法解析名称                                                            在测试tnsping的时候始终显示这么个问题. ...

  8. Inside GDALAllRegister之一: 五大部分

    基本信息 在GDAL的Tutorial中开篇即提到GDALAllRegister函数,它会注册所有已知的驱动,包括动态库自动加载的驱动.最关键是这句话: If for some application ...

  9. [置顶] IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片)

    首先了解一下CGContextRef: An opaque type that represents a Quartz 2D drawing environment. Graphics Context ...

  10. 高人对libsvm的经典总结(全面至极)

    ==>转自:http://blog.163.com/crazyzcs@126/blog/static/129742050201061192243911/ http://www.ilovematl ...