1、配置环境变量
下载最新版本的 apache-cxf-3.0.2 压缩包,解压到当前环境。如作者解压到"F:\迅雷下载\apache-cxf-3.0.2"。
在系统变量path中配置 “apache-cxf-3.0.2”。
在用户变量中配置JAVA_HOME,注意:一定得配置,而且JDK版本至少1.7以上.
配置完后,在path 系统变量中 java环境。如下图:
经过上面的步骤,webservice本地服务环境基本上搭建好。
2、服务器开发
1)服务器接口开发
package com.xiaoye.study.webservice; import javax.jws.WebService; @WebService public interface HelloWorld { public String getResult(); }
注意使用@Webservice注解表示该类是Webservice服务器接口类
2)接口实现类
package com.xiaoye.study.webservice.impl; import java.util.Date; import javax.jws.WebService; import com.xiaoye.study.webservice.HelloWorld; @WebService(endpointInterface="com.xiaoye.study.webservice.HelloWorld", serviceName="HelloWorldWS") public class HelloWorldImpl implements HelloWorld { @Override public String getResult() { return "Web Service 返回结果的时间:" + new Date(); } }
注意使用@Webservice注解,并注明接口所在类(注意使用全路径名)、服务器名称
3)服务器路口开发
package com.xiaoye.study; import javax.xml.ws.Endpoint; import com.xiaoye.study.webservice.HelloWorld; import com.xiaoye.study.webservice.impl.HelloWorldImpl; public class ServiceMain { public static void main(String[] args) { HelloWorld implementor = new HelloWorldImpl(); Endpoint.publish("http://192.168.130.203/xiaoye", implementor); } }
使用Endpoint.publish() 发布webservice。
参数:"http://192.168.130.203/xiaoye":你本机的IP和你自定义的访问名称
implementor:接口实现类对象
3、测试
启动服务器。
在浏览器地址栏输入:http://192.168.130.203/xiaoye?wsdl
打印如下内容
4、工程所需包:
相关推荐
CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx )
实战Web Service with CXF.ppt 博文链接:https://frankiehuang.iteye.com/blog/155333
CXF例子 创建服务端、客户端、相关xml的配置和环境jar说明
Apache cxf 学习笔记.pdfApache cxf 学习笔记.pdf
实战Web Service 之 CXF 实战Web Service 之 CXF
Apache CXF Web Service Development
CXF Webservice 开发手册
Web Service学习-CXF开发Web Service实例demo(一)
Apache cxf 学习笔记,供大家参考
Apache CXF Web Service Development 源码
Axis2版本学习笔记,CXF版学习笔记,WebServices学习笔记
cxf的帮助文档 . 开发web service的一个很简单的框架,很容易上手的
WebService CXF学习——入门篇 1.CXF由来 2.HelloWorld 3.WSDL描述 WebService CXF学习——进阶篇 1.SOAP讲解 2.JAX-WS讲解 3.对象传递 WebService CXF学习——高级篇(一)(二) 1.整合Spring框架 2.CXF...
cxf获取第三方天气数据包中内含: MainTest.java, WeatherWS.wsdl,使用说明文档.txt
使用CXF开发Web Service,包含服务器端和客户端
1、服务器端 Ⅰ)开发web service业务接口,该接口用@WebService修饰; Ⅱ)开发web service业务接口的实现类,也要用@WebService修饰; Ⅲ)使用EndPoint类的静态方法publish()来发布web service。 2、客户端 ...