用Axis开发Web Service
来源:互联网 发布:网络电视直播源代码 编辑:程序博客网 时间:2024/05/22 23:59
Axis是Apache的一个开源webservice引擎。它目前最为成熟的开源web service引擎之一。下面我主要介绍一下如何使用该Axis开发您的web service 服务。
1. 安装
以tomcat4.1为服务器,下面说明如何安装axis:
1. 解压下载后的包,将包中axis目录复制到tomcat目录下的webapps目录下;
2. 将axis/WEB-INF/lib目录下类文件复制到tomcat目录下的common/lib目录下;
3. 重新启动tomcat;
4. 访问http://localhost:8080/axis/happyaxis.jsp,如果能访问,表示安装成功;
2. 开发WebService服务
a.编写普通类文件,如下所示:
//文件名:Test.javaimport java.util.*;public class Test{ //fields private String name="gaga"; private int age=20; private List items=new ArrayList(); //method at here. public String getName(){ return name; } public int getAge(){ return age; } public List getItems(){ return items; }}
将本文件(Test.java)复制到Axis目录下,并将其更名为Test.jws;
b.访问http://localhost:8080/axis/Test.jws,Axis就会编译该文件,并将其部署到系统中;
下面你就可以开发web service的客户端程序了;
3. 开发客户端程序
下面是客户端程序:
import org.apache.axis.client.*;import org.apache.axis.client.Call;import org.apache.axis.client.Service;import javax.xml.namespace.QName;public class TestWebService { public static void main(String args[]) { System.out.println("Start invoking...."); try { String endpoint = "http://localhost:8080/axis/Test.jws";//你写的那个文件 Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName("getAge"); //填写你要调用的方法名称 int ret = Integer.parseInt(("" + call.invoke( new Object[] {} ))); System.out.println(ret); } catch (Exception e) { System.err.println(e.toString()); } System.out.println("Finished the invoking."); }}
关于业务调用封装到服务端程序里,然后部署就可以了,就这么简单。
4.资源
http://ws.apache.org/axis/
- 用Axis开发Web Service
- 用Axis开发Web Service
- Axis 开发web service
- 体味AXIS开发web service
- Axis开发Web Service实例
- Axis开发Web Service实例
- Axis开发Web Service实例
- 应用 AXIS 开发 Web Service
- Axis开发Web Service实例
- AXIS Web Service 开发初步
- Axis框架开发web service
- Axis开发Web Service程序
- 使用Axis开发Web Service
- 通过Axis开发Web Service
- 使用Axis开发Web Service
- 体味AXIS开发web service
- axis stubs 开发web service
- 使用axis开发web service
- 隐马尔可夫模型中的Viterbi算法
- 内存分配器dlmalloc 2.8.3源码浅析
- Arrays . sort 进行快速排序
- WebService新手入门
- 一个搞网站排名和价值评估的网站
- 用Axis开发Web Service
- 最大子矩阵问题:
- 解决ASP.NET 读取EXCEL 单元格 无法读取 空值 不显示
- android root权限破解分析
- Adb connection Error:远程主机强迫关闭了一个现有的连接
- ubuntu linux apk文件的反编译
- qq聊天记录审计
- c# log4net在项目中使用实例
- Openssl介绍