• 怎么在eclipse中访问webservice


    在eclipse创建webservice的方法:

    1、在Eclipse的菜单栏中,Window --> Preferences --> Web Service --> Axis2 Perferences,在Axis2 runtime location中选择Axis2解压缩包的位置,设置好后,点"OK"即行。

    2、新建一个webservice:

    (1)新建一个Java Project,命名为"WebServiceTest1"(2)新建一个class,命名为"CalculateService",完整代码如下:

    package edu.sjtu.webservice;  

    /** 

     * 计算器运算 

     * @author rongxinhua 

     */  

    public class CalculateService {  

        //加法  

        public float plus(float x, float y) {  

            return x + y;  

        }  

        //减法  

        public float minus(float x, float y) {  

            return x - y;  

        }  

        //乘法  

        public float multiply(float x, float y) {  

            return x * y;  

       }  

        //除法  

        public float divide(float x, float y) {  

            if(y!=0)  

            {  

                return x / y;  

            }  

            else  

                return -1;  

        }  

    }  

    (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服务。(使用浏览器打开的话使用如下地址:127.0.0.1:19189/wse/wsexplorer/wsexplorer.jsp?org.eclipse.wst.ws.explorer=3)。如下图所示:

  • 相关阅读:
    java多线程小节, 总结的不错
    奇瑞风云, 你还在路上么
    android NDK 环境建立
    外企下岗白领正成为“新4050”
    搭积木
    祝MORIENTES在LIVERPOOL有所成就
    简单生活
    为什么要更新
    归去来
    随记一笔
  • 原文地址:https://www.cnblogs.com/tuojunjie/p/6862575.html
Copyright © 2020-2023  润新知