SpringMVC4整合CXF发布WebService
SpringMVC4整合CXF发布WebService
版本:SpringMVC 4.1.6,CXF 3.1.0
项目管理:apache-maven-3.3.3
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.byref</groupId>
<artifactId>jsp-base</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>jsp-base Maven Webapp</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>3.8.1</junit.version>
<cxf.version>3.1.0</cxf.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Spring依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<!-- CXF依赖 -->
<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> </dependencies>
<build>
<finalName>jsp-base</finalName>
</build>
</project>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"> <!-- implementor为接口的具体实现类 -->
<jaxws:endpoint implementor="cn.byref.jspbase.webservice.TestWsImpl" address="/testws" ></jaxws:endpoint> </beans>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>Archetype Created Web Application</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <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>/webservice/*</url-pattern>
</servlet-mapping>
</web-app>
web服务接口:
package cn.byref.jspbase.webservice; public interface TestWS {
String helloworld();
}
接口实现:
package cn.byref.jspbase.webservice; import javax.jws.WebMethod;
import javax.jws.WebService; @WebService(targetNamespace="byref.cn.ws", portName = "testport", serviceName = "JavaServiceImpl")
public class TestWsImpl implements TestWS { @WebMethod(action = "HelloWorld",operationName = "OpName")
@Override
public String helloworld() {
System.out.println("sayHi called");
return "Hello world";
}
}
wsdl地址:http://localhost:8080/you-project-name/webservice/testws?wsdl
SpringMVC4整合CXF发布WebService的更多相关文章
- SpringBoot整合cxf发布webService
1. 看看项目结构图 2. cxf的pom依赖 1 <dependency>2 <groupId>org.apache.cxf</groupId>3 <art ...
- CXF发布webService服务以及客户端调用
这篇随笔内容是CXF发布webService服务以及客户端调用的方法 CXF是什么? 开发工作之前需要下载CXF和安装 下载地址:http://cxf.apache.org 安装过程: <1&g ...
- SpringBoot2.1.6 整合CXF 实现Webservice
SpringBoot2.1.6 整合CXF 实现Webservice 前言 最近LZ产品需要对接公司内部通讯工具,采用的是Webservice接口.产品框架用的SpringBoot2.1.6,于是采用 ...
- CXF2.7整合spring发布webservice,返回值类型是Map和List<Map>类型
在昨天研究了发布CXF发布webservice之后想着将以前的项目发布webservice接口,可是怎么也发布不起来,服务启动失败,原来是自己的接口有返回值类型是Map. 研究了一番之后,发现: we ...
- Spring集成CXF发布WebService并在客户端调用
Spring集成CXF发布WebService 1.导入jar包 因为官方下载的包里面有其他版本的sprring包,全导入会产生版本冲突,所以去掉spring的部分,然后在项目根目录下新建了一个CXF ...
- CXF整合Spring发布WebService实例
一.说明: 上一篇简单介绍了CXF以及如何使用CXF来发布一个简单的WebService服务,并且介绍了客户端的调用. 这一篇介绍如何使用CXF与spring在Web项目中来发布WebService服 ...
- Spring整合CXF发布及调用WebService
这几天终于把webService搞定,下面给大家分享一下发布webService和调用webService的方法 添加jar包 (官方下载地址:http://cxf.apache.org/downlo ...
- spring mvc + mybaties + mysql 完美整合cxf 实现webservice接口 (服务端、客户端)
spring-3.1.2.cxf-3.1.3.mybaties.mysql 整合实现webservice需要的完整jar文件 地址:http://download.csdn.net/detail/xu ...
- 使用CXF发布WebService
这里普及一下WebService和cxf的知识.关于webservice和cxf: WebService.各种提供服务的组件 .企业总线.通讯总线(ESB)CXF:是一个SOA框架,Axi ...
随机推荐
- JS练习--自动生成100个li
点击按钮,自动生成100个li,红.黄.蓝.绿四种颜色的顺序显示出现在页面中 CSS: ;;} ul,li{list-style: none;} #ul1{position: relative;} # ...
- Python(输入、输出;简单运算符;流程控制;转译)
一 输入输出 python3中统一都是input,python2中有raw_input等同于python3的input,另外python2中也有input 1.res=input("pyth ...
- cdoj1334郭大侠与Rabi-Ribi
地址:http://acm.uestc.edu.cn/#/problem/show/1334 题目: 郭大侠与Rabi-Ribi Time Limit: 3000/1000MS (Java/Other ...
- HYSBZ - 2243 染色 (树链剖分+线段树)
题意:树上每个结点有自己的颜色,支持两种操作:1.将u到v路径上的点颜色修改为c; 2.求u到v路径上有多少段不同的颜色. 分析:树剖之后用线段树维护区间颜色段数.区间查询区间修改.线段树结点中维护的 ...
- ocx的容器调试和ie调试
1 容器调试 1.1 F5,选择ActivesX Control Test Containor 1.2 ok--ok,选择工具栏的new control 1.3 在Insert Control内选择你 ...
- 什么是MSB/LSB码?
MSB是Most Significant Bit的缩写,最高有效位.在二进制数中,MSB是最高加权位.与十进制数字中最左边的一位类似.通常,MSB位于二进制数的最左侧,LSB位于二进制数的最右侧. L ...
- c语言网络通信杂笔记
1.sin_addr.s_addr = INADDR_ANY;设置成本地IP 2.pthread_create();线程生成函数 3.在linux下,sleep(1)是睡眠1s
- 无缝走A的终极技巧:学会了你也是走A怪
ADC重点之中:改键铸造更强走A! 我们先来欣赏一波来自世界顶尖ADC大师兄Doublelift的教科书般的走A. 他使用的金克丝在空蓝的情况下,凭借娴熟的走A技巧,拿下五杀. 关于走A,其实它有着一 ...
- 深入理解JVM 垃圾收集器(上)
HotSpot虚拟机中的垃圾收集器 GC评价标准 GC调优 响应时间 吞吐量 1.新生代收集器 Serial收集器 ParNew收集器 Parallel Scavenge收集器 2.老年代收集器 Se ...
- 采用DoGet方式提交中文,乱码产生原因分析及解决办法
前段时间某功能在测试机器上出现乱码,情况如下: 现象: 调试搜索功能时,通过doGet方法提交到后台的中文参数在本地和开发测试机器上为乱码(Action层),在测试人员测试机器 ...