spring mvc - cxf webservice项目
来源:互联网 发布:新华软件学校 编辑:程序博客网 时间:2024/06/05 09:39
提到cxf ,毫不避免的要说到webservice
什么是webservice,我就不多说了。
新建一个maven 项目 通过pom引用cxf的jar
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.0.4</version>
</dependency>
我用的版本是3.0.4
引入springmvc 的jar
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.0.7.RELEASE</version>
</dependency>
新建一个包com.andy.cxf
新建一个interface ITestService 如下
package com.text.service;
import javax.jws.WebService;
@WebService
public interface ITestService {
public String test();
}
新建实现类
包名com.text.service.impl
类名TestServiceImpl
内容:
package com.text.service.impl;
import javax.jws.WebService;
import com.text.service.ITestService;
@WebService
public class TestServiceImpl implements ITestService{
public String test(){
return "success";
}
}
在classpath下面新建一个beanReServer.xml 文件里面的内容如下
<?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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:endpoint id="TestFacade" implementor="com.text.service.impl.TestServiceImpl" address="/TestFacade" />
</beans>
在web.xml里面加入
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beanReServer.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
至此,成功搭建完毕,启动项目
http://localhost:8080/test-cxf
成功访问
由于cxf版本的版本差异,可能需要引入一些 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"/>
我用的3.0.4版本不需要引入
源码我已经上次,地址:http://download.csdn.net/detail/q343814703/9154103
- spring mvc - cxf webservice项目
- maven项目下使用webservice spring mvc + cxf
- Spring MVC项目中CXF webservice @Autowired实战爬坑
- webservice cxf+spring maven项目
- Spring mvc + CXF Webservice/Restful Maven
- Spring framework、Spring MVC、Apache CXF搭建webService环境
- 现有spring mvc框架利用cxf发布webservice步骤
- spring-mvc-webservice(cxf) tomcat下集成配置
- cxf+spring发布webservice
- CXF WebService整合Spring
- spring cxf webservice
- CXF+Spring 开发WebService
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF+Spring 开发WebService
- CXF WebService整合Spring
- spring cxf 开发webservice
- cxf+spring发布webservice
- 【CS学习】——UML九种图
- iOS中按钮不响应的解决方法
- 第四周项目(5):猴子选大王
- 学习ThinkPHP3.2.2:video8,判断是否post提交数据
- Leetcode 20 Valid Parentheses
- spring mvc - cxf webservice项目
- 学习ThinkPHP3.2.2:video8,_404函数已废除,用E函数替代
- 单链表的实现C++封装
- 学习ThinkPHP3.2.2:video8,用I函数解析接收的参数值
- 安卓控件使用系列22:ScrollView垂直滚动控件的使用方法
- pat1016Phone Bills (25)
- Apache Struts 2入门指南
- 学习ThinkPHP3.2.2:video8,把提交的的数据插入数据库
- 一个老程序员的5点建议