您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> 初学axis2

初学axis2

来源:网络整理     时间:2016/6/27 10:31:54     关键词:

关于网友提出的“ 初学axis2”问题疑问,本网通过在网上对“ 初学axis2”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 初学axis2
描述:

webservice

今天终于找到了一种简单的创建webservice的方法,开始拿到一篇文章,那里面使用的例子是使用了axis2-1.6.2-war 这个文件,简直误导了我,看了那一片文章后我还以为要使用axis2开发必须使用这个包呢,如果真是这样那么局限性太大了,简直没有个性可言而且访问webservice时还得使用axis2这个项目名称,感觉很不舒服;其实不然,后面看打一篇文章,写的很好一看就懂,不错 分享给初学者!   eclipse+webservice开发实例 分类: JAVA WebService2011-12-07 14:01 4071人阅读 评论(6) 收藏 举报
/> 1.参考文献: 1.利用Java编写简单的WebService实例  http://nopainnogain.iteye.com/blog/791525 2.Axis2与Eclipse整合开发Web Service  http://tech.ddvip.com/2009-05/1242968642120461.html 3.http://blog.csdn.net/lightao220/article/details/3489015 4.http://clq9761.iteye.com/blog/976029
5.使用Eclipse+Axis2+Tomcat构建Web Services应用(实例讲解篇) 2.实例1(主要看到[2]) 2.1.系统功能:  开发一个计算器服务CalculateService,这个服务包含加(plus)、减(minus)、乘(multiply)、除(divide)的操作。 2.2.开发前准备: 1. 安装Eclipse-jee; 2. 下载最新版本的Axis2,网址http://axis.apache.org/axis2/java/core/download.cgi ,选择Standard Binary Distribution的zip包,解压缩得到的目录名axis2-1.4.1,目录内的文件结构如下:   2.3.开发前配置: 在Eclipse的菜单栏中,Window --> Preferences --> Web Service --> Axis2 Perferences,在Axis2 runtime location中选择Axis2解压缩包的位置,设置好后,点"OK"即行。(如图)   2.4.开发Web Service: (1)新建一个Java Project,命名为"WebServiceTest1" (2)新建一个class,命名为"CalculateService",完整代码如下: [java] view plaincopy 1. package edu.sjtu.webservice;   2. /** 
3.  * 计算器运算  4.  * @author rongxinhua 
5.  */   6. public class CalculateService {   7.     //加法   8.     public float plus(float x, float y) {   9.         return x + y;   10.     }   11.     //减法   12.     public float minus(float x, float y) {   13.         return x - y;   14.     }   15.     //乘法  
16.     public float multiply(float x, float y) {   17.         return x * y;   18.     }   19.     //除法   20.     public float divide(float x, float y) {   21.         if(y!=0)   22.         {   23.             return x / y;   24.         }   25.         else   26.             return -1;   27.     }   28. }   (3)在"WebServiceTest1"项目上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即行。进入到Axis2 Web Service Java Bean Configuration,我们选择Generate a default services.xml,  
(8)到了Server startup对话框,有个按键"start server",点击它,则可启动Tomcat服务器了。   (9)等启完后,点击"next -- > next",一切默认即行,最后,点击完成。最后,出现如下界面:(Web Service Explorer),我们在这里便可测试我们的Web服务。(使用浏览器打开的话使用如下地址:http://127.0.0.1:19189/wse/wsexplorer/wsexplorer.jsp?org.eclipse.wst.ws.explorer=3)。如下图所示:
  注:在浏览器中打开Web Service Explorer(有时候在eclipse中关闭了webservice explorer,可以用这种方法打开)<> 首先登录地址:http://127.0.0.1:19189/wse/wsexplorer/wsexplorer.jsp。然后在网页右上角选择Web Service Exoplorer标签。然后输入WSDL地址:http://localhost:8080/WebServiceTest1/services/CalculateService?wsdl 。这个wsdl地址就是我们刚才发布服务的那个wsdl。点击go,如下图所示:  
  (10)测试比较简单,例如,我们选择一个"plus"的Operation(必须是CalculateServiceSoap11Binding),出现下图,在x的输入框中输入1,在y的输入框中输入2,点击"go",便会在status栏中显示结果3.0。其他方法的测试也类似。
解决方案1:

LZ奉献精神可嘉,鼓励鼓励,继续努力 初学axis2

解决方案2:

不错,入门步骤挺详细的。~


以上介绍了“ 初学axis2”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2104729.html

相关图片

相关文章