Web services之Axis
来源:互联网 发布:windows 桌面路径 编辑:程序博客网 时间:2024/05/28 19:23
利用Aixs2框架,在Eclipse开发平台实现Webservice服务的实现、发布、调用。
【实验环境】:
1、MyEclipse10
2、Tomcat 7..0
3、Axis2
下载axis,http://download.csdn.net/detail/u011731233/8743263把下载的war包放到tomcat的webapps目录,启动tomcat服务,在浏览器地址栏输入http://localhost:8080/axis2/验证axis安装正常
新建java project,建立下列工程目录
新建web服务文件
package com;public class Hello {public String hw(){return "hello,world";}}
创建一个services.xml的文件
<service name="Hello"> <description> helloworld example description </description> <parameter name="ServiceClass" locked="false"> com.Hello </parameter> <operation name="hw"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"></messageReceiver> </operation></service>
把这个工程打包为jar文件,然后把扩展名jar改为aar,放到TomCat目录\webapp\axis2\WEB-INF\services的目录下面,启动tomcat服务。在地址栏输入:http://localhost:8080/axis2/services/listServices 验证服务配置正常
(选中要打包的工程->右键选择Export---->java----->java file----->next----->Exported all output folders for checked project----->Export destination输入jar包存放的位置以及文件名---->finish)
新建客户端调用web服务文件
package com;import java.util.Iterator;import org.apache.axiom.om.OMElement;import org.apache.axis2.addressing.EndpointReference;import org.apache.axis2.client.Options;import org.apache.axis2.rpc.client.RPCServiceClient;public class Client {public static void main(String[] args) throws Exception {RPCServiceClient rpcClient = new RPCServiceClient();Options opt = new Options();opt.setTo(new EndpointReference("http://localhost:8080/axis2/services/Hello"));opt.setAction("urn:hw");rpcClient.setOptions(opt);OMElement element = rpcClient.invokeBlocking(new javax.xml.namespace.QName("http://com", "hw"),new Object[] { null });Iterator values = element.getChildrenWithName(new javax.xml.namespace.QName("http://com", "return"));while (values.hasNext()) {OMElement omElement = (OMElement) values.next();System.out.println(omElement.getText());}}}
0 0
- Web services之Axis
- Axis开发web services
- 用Axis开发Web Services
- Apache AXIS 开发 Web Services
- axis接用web services接口
- Apache Axis Web Services设计说明
- 基于weblogic+axis的web services开发
- 使用AXIS部署和使用web services
- Axis Web Service开发之旅 (二) --利用services.xml发布
- Axis Web Service开发之旅 (二) --利用services.xml发布
- Web Services 指南之:什么是 Web Services?
- Web Services 指南之:什么是 Web Services?
- Web Services 指南之:Web Services 综述
- 用Axis 1.1 for Java进行Web Services开发(1)
- 用Axis 1.1 for Java进行Web Services开发
- 用Axis 1.1 for Java进行Web Services开发(1)
- Axis环境之下实现web services调用EJB
- 用Apache AXIS 开发 Web Services Step By Step(1)
- opencv基础学习20150527
- linux 内核中的 __define_initcall
- android oom 全解析
- 【STL源码剖析读书笔记】【第8章】配接器
- spring的原理
- Web services之Axis
- 编译错误 在msvcrtd.lib(libcmt.lib)中重定义
- 栈和堆
- #20 Valid Parentheses
- Apache MiNa 实现多人聊天室(好文,收藏)
- PyQt4 将QTDesigner的界面 在py中展示
- Ubuntu 安装mysql
- linux c 文件操作汇总
- OGNL