axis2 安装开发教程.docx

上传人:b****4 文档编号:3017384 上传时间:2022-11-17 格式:DOCX 页数:22 大小:966.86KB
下载 相关 举报
axis2 安装开发教程.docx_第1页
第1页 / 共22页
axis2 安装开发教程.docx_第2页
第2页 / 共22页
axis2 安装开发教程.docx_第3页
第3页 / 共22页
axis2 安装开发教程.docx_第4页
第4页 / 共22页
axis2 安装开发教程.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

axis2 安装开发教程.docx

《axis2 安装开发教程.docx》由会员分享,可在线阅读,更多相关《axis2 安装开发教程.docx(22页珍藏版)》请在冰豆网上搜索。

axis2 安装开发教程.docx

axis2安装开发教程

1.软件准备:

一下软件版本为本人使用版本

Myeclipse9.0

Tomcat6.0

Jdk6

以下两项为myeclipse插件

axis2-eclipse-codegen-plugin-1.6.0.zip

axis2-eclipse-service-plugin-1.6.0.zip

以下zip包为tomcat插件

axis2-1.6.0-war.zip

axis2中的jar,在客户端开发中需要用到这些jar包

axis2-1.6.0-bin.zip

2.myeclipse插件安装

将axis2-eclipse-codegen-plugin-1.6.0.zip和

axis2-eclipse-service-plugin-1.6.0.zip解压

 

D:

\Users\Administrator\AppData\Local\MyEclipse为我的myeclipse安装的根目录

将解压后的plugins中的jar包复制到myeclipse的安装目录下的common中的plugins中(只需jar包即可)如:

D:

\Users\Administrator\AppData\Local\MyEclipse\Common\plugins

进入到myeclipse安装目录中的org.eclipse.equinox.simpleconfigurator中,如下:

D:

\Users\Administrator\AppData\Local\MyEclipse\MyEclipse9\configuration\org.eclipse.equinox.simpleconfigurator

用记事本打开org.eclipse.equinox.simpleconfigurator中的bundles.info文件

项bundles.info文件中添加下面内容

org.apache.axis2.eclipse.codegen.plugin,1.6.0,file:

/d:

/Users/Administrator/AppData/Local/MyEclipse/Common/plugins/org.apache.axis2.eclipse.codegen.plugin_1.6.0.jar,4,false

org.apache.axis2.eclipse.service.plugin,1.6.0,file:

/d:

/Users/Administrator/AppData/Local/MyEclipse/Common/plugins/org.apache.axis2.eclipse.service.plugin_1.6.0.jar,4,false

启动myeclipse后点击新建other后如果能看到Axis2Wizards文件夹下有两个内容表示安装成功。

3.tomcat安装

将tomcat6.0解压到某个目录中,这里使用的时免安装版的

在系统环境变量中添加:

TOMCAT_HOME=D:

\webservice\tomcatapache-tomcat-6.0.32

CATALINA_BASE=D:

\webservice\tomcat\apache-tomcat-6.0.32

CATALINA_HOME=D:

\webservice\tomcat\apache-tomcat-6.0.32

在path中添加

%TOMCAT_HOME%/lib

在浏览器中输入http:

//localhost:

8080看到tomcat的主页说明安装配置成功

解压axis2-1.6.0-war.zip后得到一个axis2.war的文件,将该文件复制到D:

\webservice\tomcat\apache-tomcat-6.0.32\webapps目录下

启动tomcat,之后会自动生成一个axis2的文件夹,该文件夹在D:

\webservice\tomcat\apache-tomcat-6.0.32\webapps下

在浏览器中输入http:

//localhost:

8080/axis2/

看到

说明axis2web服务器搭建成功

到此开发环境搭建完成.

4.服务器端发布

启动myeclipse新建一个java工程

写一个服务器端的类向客户端返回一个字符串

packagecom.test;

publicclassTest{

publicStringserver(Stringname)

{

return"Hello"+name;

}

}

进行打包:

1在当前项目上右击选择export

2双击JARfile

3选择当前项目并且点击browse选择jar的输入目录和输入生成的jar包文件名称

4点击finish完成jar包打包

5.打包arr

6.在该项目上右击newotherAxis2WizardsAxis2ServiceArchiver

7选择arr包得输入目录,点击next

8选择skipwsdlnext

9点击brows选择前面已经打包好jar包

10点击addnext

11选中复选框next

12输入自己的定的servername,输入完整Class名点击load,下面出来该类中的所有方法,如果选中,就会发布此方法,客户掉便可以调用

13nextbrowse选择outputfilelocation,选择arr文件的数据路径,输入arr文件的名称,点击finish完成。

14发布arr,将打包好的arr文件复制到D:

\webservice\tomcat\apache-tomcat-6.0.32\webapps\axis2\WEB-INF\services目录下,重新启动tomcat,在浏览其中输入http:

//localhost:

8080/axis2,点击service进入如下界面

可以看到testAxis(在打包arr时自定义的名称)点击testAxis可以查看xml,表示发布成功,可以在客户端进行调用。

15客户端,新建一个java工程,编写客户端代码

16右击newotherAxis2WizardsAxis2CodeGeneratornext

17选择第一个单选按钮next

18在浏览器中输入http:

//localhost:

8080/axis2-->选择services-->testAxis,进入一个xml界面,复制浏览器中地址(http:

//localhost:

8080/axis2/services/testAxis?

wsdl),粘贴到WSDLfilelocation中,点击next

19保持默认,next

20选择客户端的工程,outputpath的值是新建的这个客户端的工程,nextokfinish

21在myeclipse界面中的packageexplorer窗口中可以看到新建的testAxis工程自动生成了一个包,包名是服务器端工程的包名,目前有很多错误,是因为没有导入jar包

22导入jar,首先解压axis2-1.6.0-bin.zip,将lib中的所有jar导入到客户端工程中

D:

\webservice\axis2-1.6.0\lib

没有错误了

23调用服务端的方法,或得返回值

在axisClient工程中新建一个类Test

importjava.rmi.RemoteException;

importcom.test.Server;

importcom.test.TestAxisStub;

publicclassTest{

publicstaticvoidmain(Stringargs[])throwsRemoteException

{

//首先新建一个stub的对象(桩)

TestAxisStubtas=newTestAxisStub();

//实例化服务端的方法的对象

Servers=newServer();

//为server方法设置参数

s.setName("john");

//执行该方法,并且接受返回值

Stringstr=tas.server(s).get_return();

System.out.println(str);

}

}

开启tomcat,运行Test.java,得到服务器返回的值。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 艺术创意

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1