使用Axis2-1.6.1实现第一个Web Service
2015-02-08 16:26
239 查看
使用Axis2-1.6.1实现第一个Web Service
教程是对51CTO视频教程的文字总结及个人实践首先下载Axis2,我下载Binary Distribution的axis2-1.6.1-bin.zip和WAR Distribution的axis2-1.6.1-war.zip。
安装
将axis2-1.6.1-war.zip解压得到的axis2.war文件复制到Tomcat安装目录下webapps文件夹中,启动Tomcat即可。Tomcat安装目录下webapps文件夹中生成了axis2文件夹。编写Web Service类
编写一个SimpleServicce类:[code]public class SimpleService{ public String getGreeting(String name){ return "hello " + name; } public int getPrice(){ return new java.util.Random().nextInt(100); } }
打开cmd命令窗口,使用javac SimpleService.java命令编译得到SimpleService.class文件。
发布Web Service
将Web Service类编译生成的.class文件,即上一步得到的SimpleService.class文件复制到Tomcat安装目录\webapps\axis2\C:\Tomcat\webapps\axis2\WEB-INF\pojo文件夹中,没有pojo文件夹请自行创建。不用重启Tomcat该SimpleService已经热发布成功。可以使用如下URL查看已经发布的Web Service列表:http://localhost:8080/axis2/services/listServices
点击SimpleService可以看到关于该Web Service的wsdl描述我的本地地址为http://localhost:8080/axis2/services/SimpleService?wsdl
其中
<xs:element name="getGreeting"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="args0" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
定义了getGreeting方法参数name为args0,接下来可以使用URL测试getGreeting方法:http://localhost:8080/axis2/services/SimpleService/getGreeting?args0=world
得到如下结果:
[code]<ns:getGreetingResponse xmlns:ns="http://ws.apache.org/axis2"> <return>hello world</return> </ns:getGreetingResponse>
下一篇将介绍使用java RPC方法调用Web Service和wsdl2java命令的使用。
相关文章推荐
- 使用axis2实现web service(三)
- 使用axis2实现web service(三)
- 使用axis2实现web service接口(一)
- 使用Axis2实现Web Service的用户会话
- 使用axis2实现web service接口(一)
- 使用Axis2实现Web Service的用户会话
- 显示第一个view, 延迟三秒再显示第二个view,使用java的定时器timer实现 需要启动两个activity
- 使用Axis2来构建Web Service客户端
- 使用Axis2的底层API开发Web Service
- 在Atlas服务器端实现中推荐使用Web Service而不是Page Method
- 服务使用CXF框架客户端使用Axis2框架的webservice实现方案
- 使用Axis2来构建Web Service客户端
- Biztalk Server------使用WCF-BasicHttp Adapter在Orchestration中实现无Reference的Web Service调用
- 使用WSE实现Web Service安全
- 使用Axis2调用Web Service
- 使用WSE实现Web Service安全(zhuan)
- 在WinForm中使用Web Service来实现软件自动升级
- 使用WSE实现Web Service安全(web.config)
- 使用WSE实现Web Service安全
- 新一代Web Service 实现包 -- AXIS2 学习笔记 (二)