cxf介绍study

来源:互联网 发布:淘宝激活店铺激活不了 编辑:程序博客网 时间:2024/05/16 05:51
 1.首先集成Apacha CXF WebService 到 Spring 框架中;
apache cxf 下载地址:http://people.apache.org/dist/incubator/cxf/2.0.4-incubator/apache-cxf-2.0.4-incubator.zip
在spring context配置文件中引入以下cxf配置
<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" />

在web.xml中添加过滤器:
<servlet><servlet-name>CXFServlet</servlet-name><servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class></servlet><servlet-mapping><servlet-name>CXFServlet</servlet-name><url-pattern>/services/*</url-pattern></servlet-mapping>


2.开发服务端WebService接口:
/*** WebService接口定义类.* * 使用@WebService将接口中的所有方法输出为Web Service.* 可用annotation对设置方法、参数和返回值在WSDL中的定义.*/@WebServicepublic interface WebServiceSample {/*** 一个简单的方法,返回一个字符串* @param hello* @return*/String say(String hello);/*** 稍微复杂一些的方法,传递一个对象给服务端处理* @param user* @return*/String sayUserName(@WebParam(name = "user") UserDTO user);/*** 最复杂的方法,返回一个List封装的对象集合…………………………………………………………………………<p style="COLOR: red; FONT-SIZE: 16px"><strong>来自:<a target=_blank href="http://www.verydemo.com/demo_c143_i29102.html" target="_blank">http://www.verydemo.com/demo_c143_i29102.html</a></strong></p>
0 0
原创粉丝点击