Axis2与Eclipse整合开发Web Service
系统功能: 开发一个计算器服务CalculateService,这个服务包含加(plus)、减(minus)、乘(multiply)
、除(divide)的操作。
开发前准备:
1、安装Eclipse-jee;
2、下载Axis2的最新版本Axis2 1.4.1 Release,网址
http://ws.apache.org/axis2/download/1_4_1/download.cgi ,选择Standard Binary Distribution
的.zip包即"axis2-1.4.1-bin.zip"这个文件,解压缩得到的目录名axis2-1.4.1,目录内的文件结构如
下:
开发前配置:在Eclipse的菜单栏中,Window --> Preferences --> Web Service --> Axis2
Perferences,在Axis2 runtime location中选择Axis2解压缩包的位置,设置好后,点"OK"即行。(如图
)
开发Web Service:
1、新建一个Java Project,命名为"WS_01";
2、新建一个class,命名为"CalculateService",完整代码如下:
package rong.service; /** *//** * 计算器运算 * @author rongxinhua * */ public class CalculateService { /** *//** * 加法运算 * @param x 被加数 * @param y 加数 * @return x与y的和 */ public float plus(float x, float y){ return x + y ; } /** *//** * 减法运算 * @param x 被减数 * @param y 减数 * @return x与y之差 */ public float minus(float x, float y){ return x - y ; } /** *//** * 乘法运算 * @param x 被乘数 * @param y 乘数 * @return x与y的乘积 */ public float multiply(float x, float y){ return x * y ; } /** *//** * 除法运算 * @param x 被除数 * @param y 除数 * @return x与y的商 */ public float divide(float x, float y){ return x / y ; } }
3、在"WS_01"项目上new --> other,找到"Web Services"下面的"Web Service";
4、下一步(next),在出现的Web Services对象框,在Service implementation中点击"Browse",进入
Browse Classes对象框,查找到我们刚才写的写的CalculateService类。(如下图)。点击"ok",则回到
Web Service话框。
5、在Web Service对话框中,将Web Service type中的滑块,调到"start service“的位置,将Client
type中的滑块调到"Test client"的位置。
6、在Web Service type滑块图的右边有个"Configuration",点击它下面的选项,进入Service
Deployment Configuration对象框,在这里选择相应的Server(我这里用Tomcat6.0)和Web Service
runtime(选择Apache Axis2),如下图:
7、点OK后,则返回到Web Service对话框,同理,Client type中的滑块右边也有"Configuration",也
要进行相应的置,步骤同上。完成后,Next --> next即行。
8、到了Server startup对话框,有个按键"start server"(如下图),点击它,则可启动Tomcat服务器
了。
9、等启完后,点击"next -- > next",一切默认即行,最后,点击完成。最后,出现如下界面:(Web
Service Explorer),我们在这里便可测试我们的Web服务。
10、测试比较简单,例如,我们选择一个"plus"的Operation,出现下图,在x的输入框中输入2,在y的
输入框中输入3,点击"go",便会在status栏中显示结果5.0。其他方法的测试也类似。
到这里用Axis2与Eclipse整合开发的Web Service的服务端和客户端就成功了。你也试试吧!
摘自:http://tech.ddvip.com/2009-05/1242968642120461.html
相关推荐
Axis2与Eclipse整合开发的Web Service的服务端
目前axis2最高版本是2.0以上的版本,但是eclipse和myeclipse都不支持,无奈只能使用低版本的插件1.6.3;经实验,可以安装成功;...axis2-eclipse-service-plugin-1.6.3.zip axis2-eclipse-codegen-plugin-1.6.3.zip
包括axis2-eclipse-codegen-plugin-1.7.9.zip和axis2-eclipse-service-plugin-1.7.9.zip,共享给有需要的
共四个文件,都是最先版的,希望可以帮助大家。axis2-eclipse-service-archiver-wizard和axis2-eclipse-codegen-wizard和axis2-1.6.1-bin和axis2-1.6.1-war
axis2-eclipse插件
axis2-eclipse-codegen-plugin-1.6.2.zip和axis2-eclipse-service-plugin-1.6.2.zip,解压即可使用
标签:axis2.eclipse.service.plugin-1.5.jar,axis2.eclipse.service.plugin,1.5,jar包下载,依赖包
axis2-eclipse-service-archiver-wizard.zip
利用Java编写简单的WebService实例 Axis2与Eclipse整合开发Web Service
标签:axis2.eclipse.service.plugin-1.5.1-sources.jar,axis2.eclipse.service.plugin,1.5.1,sources,jar包下载,依赖包
axis2-eclipse-codegen-plugin-1.6.0和axis2-eclipse-service-plugin-1.6.0有关jar包下载,解压后直接将这两个jar包放到eclips下的plugins目录下,重启eclipse即可
org.apache.axis2.eclipse.service.plugin_1.7.8插件文件,欢迎小伙伴下载
绝对可以用,里面配有myeclipse10安装AXIS2插件的步骤,希望大家工作愉快,谢谢,给好评哦
axis2-eclipse-codegen-plugin-1.6.2+axis2-eclipse-service-plugin-1.6.2
1.1 Axis2(Eclipse)插件的安装。 1.2 Axis2.war的安装。 1.3 Eclipse Build Path。 二、 Web Service服务器端的发布。 2.1 创建java类。 2.2 创建services.xml。 2.3 发布服务。 2.4 在浏览器上测试服务。 三、 ...
axis2 WebService eclipse插件,直接放在\dropins根目录下
标签:axis2.eclipse.service.plugin-1.5-sources.jar,axis2.eclipse.service.plugin,1.5,sources,jar包下载,依赖包
axis2-eclipse-service-plugin-1.5.4.zip
axis2-eclipse-codegen-plugin-1.6.1和axis2-eclipse-service-plugin-1.6.1的eclipse插件