依赖jar文件:
axiom-api-1.2.7.jar
axis2-kernel-1.4.1.jar
jboss-backport-concurrent.jar
commons-httpclient-3.1.jar
commons-codec-1.3.jar
axiom-impl-1.2.7.jar
第一步:定义接口
package com.web.service;
import javax.jws.WebParam;
import javax.jws.WebService;
//@WebService(name = "TestService",targetNamespace = "http://service.web.com/")
@WebService
public interface ITestService {
//@WebMethod(action = "http://service.web.com/myService")
public String myService(@WebParam(name = "param")String param);
}
第二步:建立实现类
package com.web.service;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(endpointInterface = "com.web.service.ITestService")
public class TestService implements ITestService {
/**
* 测试webservice
*/
public String myService(@WebParam(name = "param")String param) {
System.err.println(">>>>>>>>>>"+param+">>>>>>>>>>>>>>>>>>>>>test first webservice!!!");
return param;
}
}
第三步:进行webservice发布配置
<?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.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-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
<!-- 配置 WEB Service 开始-->
<bean id="ITestService" class="com.web.service.TestService"/>
<bean id="TestService_jaxWsServiceFactoryBean" class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="true" />
<property name="dataBinding" ref="aegisBean" />
</bean>
<jaxws:endpoint id="TestService" implementor="#ITestService" address="/TestService">
<jaxws:serviceFactory>
<ref bean="TestService_jaxWsServiceFactoryBean"/>
</jaxws:serviceFactory>
</jaxws:endpoint>
<!-- 配置 WEB Service 结束-->
</beans>
第三步:在项目web.xml中加入如下配置
<!-- WEB SERVICE 配置开始 -->
<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>/ws/*</url-pattern>
</servlet-mapping>
<!-- WEB SERVICE 配置结束 -->
分享到:
相关推荐
springboot+cxf实现webservice示例 <groupId>org.springframework.boot <artifactId>spring-boot-starter <groupId>org.springframework.boot <artifactId>spring-boot-starter-web <!-- CXF ...
cxf组件 webservice示例代码
JAVA CXF webservice的示例代码 Eclipse工程
借鉴网上例子,弄了一个SpringBoot开发WebService之CXF示例。
readme下为开发文档。 1.集成 spring 2.集成 WSS4J 3.mtom 功能示例 4.基本数据类型service接口 示例 5.复杂数据类型service接口 示例
1. 发布和调用WebService: 使用CXF2.4(http://cxf.apache.org)和spring 2. 调用安全性: 使用简单的USERNAME_TOKEN 3. 服务程序中取得调用者身份 ------------------------- 接口 ------------------------- intf....
CXF框架开发WebService示例及说明
现在主流的webService框架,一个是axis2,一个是cxf,本资源是基于cxf框架的简单例子
Webservice入门教程_用CXF编写基于Spring的WebService示例代码
CXF构建WebService示例,具有一定的参考价值,可供学习
CXF WebService整合Spring示例工程代码demo可以直接导入eclipse。参照网页http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html 完成的webService服务提供。 大致步骤: 1.引入cxf和其他需要的jar包,(本...
本实例工程使用Apache CXF组件快速开发WebService。基于Spring框架,使用了Maven项目,但由于时间原因,只使用了Maven Project的框架,还是使用lib文件夹存放所需的cxf库,传入传出对象支持Json格式。
基于CXF的WebService服务端和客户端示例,CXF+Spring,希望能为WebService开发者提供帮助。WebService,CXF,Spring.
完整可用的spring整合CXF示例项目,包括服务发布端和调用端两个项目,包括CXF拦截器的实现的简单的授权校验
cxf开发webservice客户端和服务器端,详细的cxf使用指令,有用的示例代码及注释。
webservice示例(cxf开发的例子),简单的例子。可以学学。
使用cxf wsdl2java生成webservice客户端命令
spring整合cxf实现restful的webservice服务,代码分为服务端和客户端两个模块;服务端为接口,客户端为接口调用。
cxf简单示例.chm,学习cxf,webservice