一、准备

1、下载Axis2、eclipse插件

axis2-1.6.2-war.zip:

http://mirror.bjtu.edu.cn/apache//axis/axis2/java/core/1.6.2/axis2-1.6.2-war.zip

axis2-1.6.2-bin.zip:

http://mirror.bjtu.edu.cn/apache//axis/axis2/java/core/1.6.2/axis2-1.6.2-bin.zip

axis2-eclipse-codegen-plugin-1.6.2.zip:

http://www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.6.2/axis2-eclipse-codegen-plugin-1.6.2.zip

axis2-eclipse-service-plugin-1.6.2.zip:

http://www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.6.2/axis2-eclipse-service-plugin-1.6.2.zip

2、部署

解压axis2-1.6.2-war.zip将axis2.war部署到tomcat,并访问http://localhost:8080/axis2/

3、安装eclipse插件

解压插件,直接将文件拷到plugins目录中。打开eclipse,在package explorer 中点击右键--->选择new---->other

二、开发服务端

1、建Java Project项目,名称为“myservice”,并创建服务类

  1. package com.my.server;
  2. public class SimpleServer {
  3. public String simpleMethod(String name) {
  4. return name + "说:走别人的路,让别人无路可走。";
  5. }
  6. }

1、在eclispe 的package Explorer 中点击右键,在菜单中选择新建--->other...----->Axis2 Service Archiver。

2、点击next进入类选择页面,在Class File Location选择框中选择类所在的文件夹,即java.class文件所存放位置的根目录。

3、点击next进入选择 wsdl文件,选择skip wsdl。

4、点击next进入选择jar文件页面。(没有用到外部jar,点击next直接跳过)

5、点击next进入选择xml页面。勾选Generate the service xml automatically。

6、点击next进入生成xml文件页面。在service name 里填写这个服务所起的名字(simpleServer),在class name中填写要发布的类(全路径),然后点击load 按钮。

7、点击next 进入的是输出artiver文件页面,先在output File location 中选择要输出的路径,在output  File Name中输入artiver文件的名称(simpleServer)。

8、点击finish ,如果看到如下的画面,恭喜你,服务发布成功啦。

9、把aar文件放入tomcat中发布。

把生成的aar文件拷贝到tomcat目录中的axis2项目的service目录中位置如图。

10、启动tomcat,在地址栏中输入http://localhost:8080/axis2 ,你会看到axis2的欢迎画面。


 

 

三、开发客户端

将Dynamic web Project项目,名称为client。

1、在eclispe 的package Explorer 中点击右键,在菜单中选择新建--->other...----->Axis2 Code Generator。

2、点击next进入,选择从wsdl文件来产生java文件。

3、点击next然后选择wsdl文件。

4、点击next,进入设置页面,用默认的设置。

5.、点击next,选择输出文件的路径。

6、点击next,如果看到这个页面,已经生成代码成功。

7、引入jar包(\axis2-1.6.2\lib)。

8、编写测试方法调用服务。

import com.my.server.SimpleServerStub;

public class SimpleClient {  

 public static void main(String[] args) throws Exception{  

  //初始化桩文件
SimpleServerStub stub = new SimpleServerStub();
//初始化SimpleMethod方法。
SimpleServerStub.SimpleMethod request = new SimpleServerStub.SimpleMethod();
//调用simpleMethod的setName方法。
request.setName("zt");
//
System.out.println(stub.simpleMethod(request).get_return());
}
}

参考:http://blog.csdn.net/yangsen251024/article/details/7043043

最新文章

  1. 08. Web大前端时代之:HTML5+CSS3入门系列 ~ QQ空间时间轴
  2. 使用javascript和canvas画月半弯
  3. 【Spring】获取资源文件+从File+从InputStream对象获取正文数据
  4. thinkPHP 5.0.x 使用SQLite3 进行缓存设置 Cache
  5. OracleHelper数据库事务处理
  6. SVN 搭建
  7. 未能加载文件或程序集"Microsoft.Web.Infrastructure 的解决方案
  8. SequoiaDB 系列之二 :SequoiaDB的简单CRUD操作
  9. 使用GitHub进行团队合作
  10. T-SQL基础 (存储过程,触发器|| 笔记0808)
  11. 用C++试着完成Python简明教程后面的练习
  12. Android获取设备隐私 忽略6.0权限管理
  13. cortex m0 lpc1114的NVIC中断如何使用
  14. 杯具,万达电商又换CEO
  15. 1.自定义控制器切换<一>
  16. 解决PL/SQL Developer 连接oracle 11g 64位中的问题
  17. 抽象,接口和Object类
  18. DateTime?,也是一种类型,代表DateTime或NULL两种类型,在处理空时间时比较有用
  19. 14.python-CS编程
  20. 『OpenCV3』Mat简介

热门文章

  1. enq: TX - row lock contention“等待事件的处理
  2. JSP标签:jsp内置标签、jstl标签、自定义标签
  3. Leetcode 388.文件的最长绝对路径
  4. hlgoj1881
  5. 公钥密码之RSA密码算法扩展欧几里德求逆元!!
  6. ngrinder的idea脚本开发环境配置
  7. FOJ Problem 2271 X
  8. SpringBoot项目整合Druid进行统计监控
  9. 了解Chrome扩展程序开发--摘抄
  10. [bzoj1345][Baltic2007]序列问题_单调栈