用axis+Tomcat+Eclipse部署和访问Web服务(zhouhuayun).docVIP

  • 2
  • 0
  • 约 12页
  • 2017-02-02 发布于江苏
  • 举报

用axis+Tomcat+Eclipse部署和访问Web服务(zhouhuayun).doc

实例:用axis2+Tomcat5.5+Eclipse3.2部署和访问Web服务部署并访问一个Web服务,部署环境: axis2 + Tomcat5.5 + Eclipse3.2来部署和访问Web服务,步骤如下: 1. 从/ws/axis2/1_1_1/ 下载 axis2-1.1.1.zip 解压到 C:\JavaPlatform\axis2 2. 执行 C:\JavaPlatform\axis2\bin\axis2server.bat 3. 用ant命令执行 C:\JavaPlatform\axis2\webapp下的build.xml,执行完 后会在目录 C:\JavaPlatform\axis2\dist下产生axis2.war,将axis2.war包拷贝到tomcat安装目录下的webapps目录。启动Tomcat,打开浏览器输入并访问::8080/axis2 来查看,结果如下图,表示axis2已经工作正常。 4. 下载Axis Eclipse plug-in(代码生成工具和打包工具): /ws/axis2/tools/1_1_1/axis2-eclipse-codegen-wizard.zip /ws/axis2/tools/1_1_1/axis2-eclipse-service-archiver-wizard.zip 解压到 eclipse主目录的plugins下,启动Eclipse后,File ? New ? Other 会发现多了如下两项: ? 5.在Eclispse中添加一个用户库命名为axis2,将axis2\lib下的包均添加进来。 6. 建立一个JavaProject命名为AccountService,将axis2用户库加入到build path中。项目存放路径先Tomcat的webapps下。在project中建立WEB-INF, META-INF两个web项目常用目录及子目录和文件,并建立资源存放文件夹src。并将WEB-INF\classes设置为编译文件输出位置。 7. 现在开始编写要发布的WebSevice,在src中建包account,建立AccountOper类如下: package account; public class AccountOper { ?? ?private static int[] fund = {10000, 500, 700, 5800}; ?? ?public static int accountID = 0;//in {0,1,2} ?? ?public boolean setAccountID( int id ) { ?? ??? ?if(id 0 || id fund.length) ?? ??? ??? ?return false; ?? ??? ?this.accountID = id; ?? ??? ?return true; ?? ?} ?? ? ?? ?public boolean checkInput(int money) ?? ?{ ?? ??? ?if (money fund[accountID]) { ?? ??? ??? ?return false; ?? ??? ?} else { ?? ??? ??? ?return true; ?? ??? ?} ?? ?} ?? ?//deposit ?? ?public int deposit(int money) ??? { ?????? fund[accountID] = fund[accountID] + money; ?????? return fund[accountID]; ??? } ?? ?//withdraw ?? ?public int withdraw(int money) { ?? ??? ?if (checkInput(money)) { ?? ??? ??? ?fund[accountID] = fund[accountID] - money; ?? ??? ?} ?? ??? ?return fund[accountID]; ?? ?} ?? ?public int getAccount() { ?? ??? ?return fund[accountID]; ?? ?} } 8. 在META-INF下建立services描述文件services.xml如下: service name=AccountService ?parameter name=ServiceClass ????????? locked=falseaccount.AccountOper/parameter ?operation name=setAccount

文档评论(0)

1亿VIP精品文档

相关文档