此文章是基于
搭建Jquery+SpringMVC+Spring+Hibernate+MySQL平台
一. 简介
WebService有两种方式,一是SOAP方式,二是REST方式。SOAP是基于XML的交互,WSDL也是一个XML文档,
可以使用WSDL作为SOAP的描述文件;REST是基于HTTP协议的交互,支持JSON、XML等交互,不需要WSDL。
二. 准备工作
1. 点击此下载相关文件,并把文件放到 ims 工程对应的文件夹下
三. jar包介绍
1. 点击此下载 apache-cxf-3.0.3,并在 lib 文件夹下得到:
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
commons-codec-1.9.jar
cxf-core-3.0.3.jar
cxf-rt-frontend-jaxrs-3.0.3.jar
cxf-rt-transports-http-3.0.3.jar
javax.ws.rs-api-2.0.1.jar
2. commons-httpclient-3.1.jar
四. 相关程序代码
1. applicationInterface.xml:spring配置文件
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
<?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <!-- cxf发布rest服务 --> <import resource="classpath:META-INF/cxf/cxf.xml"/> <!-- 这里是cxf2.x版本的配置,3.0没有了要去掉 --> <!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> --> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <bean id="rec