axis2 webService服务搭建

9 篇文章 0 订阅

用这个搭建webWervice相对简单。步骤如下:

一、下载tomcat,运行

二、下载axis2-1.6.2-war.zip (下载地址http://download.csdn.net/detail/cyw8998/7487243),解压下载包后,把axis2-1.6.2.war放到tomcat的webapps目录下

三、启动tomcat,用浏览器打开http://localhost:8080/axis2/ 

可以看到

  • Services
    View the list of all the available services deployed in this server.
  • Validate
    Check the system to see whether all the required libraries are in place and view the system information.
  • Administration
    Console for administering this Axis2 installation.

     

    点击第一个Services 里边就是我们的服务java类

     

     四、编写最简单的服务用的Axis2ServiceTest.java

    public class Axis2ServiceTest{

        public String sayHello(String name) {  
         return "hello" + name;  
        }

  • 编译完这个java文件后,把Axis2ServiceTest.class文件拷贝到tomcat\webapps\axis2\WEB-INF\pojo 文件夹下(pojo是默认识别的文件夹),重新启动tomcat,

  • 用浏览器打开http://localhost:8080/axis2/  ,之后在 Services下可以看到如下

  •  

    Axis2ServiceTest

    Service Description : No description available for this service
    Service EPR : http://localhost:8080/axis2/services/Axis2ServiceTest
    Service Status : Active

    Available Operations
    • sayHello

    sayHello就是服务方法,接下来,用浏览器以外的方式就可以访问了,下一篇讲如何用android应用程序访问这个服务,调用sayHello方法

     

    ****************************

    另:

    1、每次编写一个服务,重新编译和拷贝,必须重启tomcat,因为要重新加载.class文件,如果嫌麻烦,不想重启tomcat,那也有办法,改一下配置文件

    \tomcat-6.0.26\webapps\axis2\WEB-INF\conf\axis2.xml

    找这个<parameter name="hotupdate">true</parameter>  这样true就代表更新后的热部署,这会每写完一个服务,拷贝到对应木木后,就不用重新启动 tomcat了

    2、pojo目录是默认的,如果不喜欢这个目录,就在这个目录同级别,建立另一个目录,比如叫my

    这回还是得改

    \tomcat-6.0.26\webapps\axis2\WEB-INF\conf\axis2.xml

    不然my目录不被检索识别

    axis2.xml中,搜索<deployer extension=".class"

    加入

    <!-- extension -->
     <deployer extension=".class" directory="my" class="org.apache.axis2.deployment.POJODeployer"/>

    之后,重启tomcat,my目录下加入新的服务.class文件,就被识别了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值