一、下载CXF的jar包:所需要的jar包
二、创建Server端,创建CXF_Server项目
1、导入所需根据jar包
2、新建一个接口
import javax.jws.WebService; @WebService public interface HelloWorld { public String sayHi(String name); }
3、新建一个接口实现类
@WebService(endpointInterface="com.tzz.cxf.ws.HelloWorld",serviceName="HelloWorldWs") public class HelloWorldWs implements HelloWorld{ @Override public String sayHi(String name) { String str = name + ",您好,现在时间是"+new Date(); System.out.println("server---------"+str); return str; } }
说明:
@WebService:申明为webservice的注解
endpointInterface:要暴露的接口类
serviceName :服务名,其实就是调用地址
4、发布服务
public class ServerMain { public static void main(String[] args) { HelloWorld helloWorld = new HelloWorldWs(); Endpoint.publish("http://127.0.0.1/helloworld:8082", helloWorld); } }
5、运用ServerMain类启动服务,浏览器输入http://127.0.0.1/helloworld:8082?wsdl地址,访问成功,说明服务启动成功,CXF服务端构造完成
三、创建Client端,创建CXF_Client项目
1、将下载的CXF中的bin加入到系统环境变量path中:
1.1、新建变量CXF_HOME,CXF_HOME=“E:\\apache-cxf-.7.14”
1.2、在path中加入;%CXF_HOME%\bin
2、利用wsdl2java生成客服端代码
3、Client端调用Server端的服务
public class ClientMain { public static void main(String[] args) { HelloWorldWs helloWorldWs = new HelloWorldWs(); HelloWorld helloWorld = helloWorldWs.getHelloWorldWsPort(); String str = helloWorld.sayHi("test"); System.out.println("Client---------"+str); } }
4、运行ClientMain类
5、输出结果
Client---------test,您好,现在时间是Fri Jan 16 21:58:12 CST 2015
相关推荐
现在主流的webService框架,一个是axis2,一个是cxf,本资源是基于cxf框架的简单例子
CXF webservice,mybatis持久层框架,增删改查实例;完整jar包;
学习CXF WebService入门实例一.pdf学习CXF WebService入门实例一.pdf
CXF WebService java实例 例子包括基本的 HelloWord列子 还有传递List ,Map的列子 另外还有webservice 文件下载上传的示例
SSH整合cxf webservice实例
cxf webservice 简单例子 服务端 客户端 com.test.ClientTest 进行测试,导入myeclipse可以直接运行
mybatis+spring+cxf webservice服务 项目框架代码例子,绝对是可以参考的,信不信,只有下载之后才知道
使用 CXF 做 webservice 简单例子,用的是cxf-2.1.3.jar
一个小例子希望能对你有所帮助 CXF webservice spring例子 将cxf2.4的lib复制到工程lib下
cxf webservice 与spring整合的开发实例
webservice天气预报例子cxf实例,
CXF-webService实例(eclipse工程,有jar包,可运行) jax-ws和pojo两种方式发布
这是一个用cxf进行webservice开发的小例子,解决了no cxf bean等小问题,采用maven组织,接口可通过web发布,并带了测试demo。整个过程参考:http://developer.51cto.com/art/201205/333868.htm,大家可以继续完善
NULL 博文链接:https://jie66989.iteye.com/blog/1700437
CXF实现WebService详解实例
使用CXF开发简单HelloWorld实例
Spring + cxf = webservice 完整实例源码免费下载 完全免费。此资源仅为文档提供。 版权为百度文档 "Spring + cxf = webservice 完整实例源码免费下载" 所有。
springboot整合CXF发布webservice和客户端调用 项目中每个类都有详细的注释,保证都能看懂,不失为一个学习springboot整合cxf来学习webservice发布调用的好例子
cxf webservice实例