利用axis2将SSH项目发布成Web Service
1.开发环境
eclipse,axis2 war,SSH项目
axis2 的eclipse插件:
axis2-eclipse-codegen-wizard.zip 用于生成stub本地代码
axis2-eclipse-service-archiver-wizard.zip 用于发布web service
2.安装过程
1.下载完2个插件的压缩文件后,可以直接把解压后的文件拷贝到eclipse 的 plugins目录中
从axis2 bin 包里找到:backport-util-concurrent-3.1.jar 和 geronimo-stax-api_1.0_spec-1.0.1.jar
复制到 eclipse\plugins\Axis2_Codegen_Wizard_1.3.0\lib 文件夹下。
backport-util-concurrent-3.1.jar 需要在网上download site:http://www.findjar.com/jar/mule/dependencies/maven2/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar.html
2.修改eclipse\plugins\Axis2_Codegen_Wizard_1.3.0\plugin.xml 文件
在 <runtime> 內加入下面的字串
<library name="lib/geronimo-stax-api_1.0_spec-1.0.1.jar">
<export name="*"/>
</library>
<library name="lib/backport-util-concurrent-3.1.jar">
<export name="*"/>
</library>
3.把Axis2_Codegen_wizard_1.3.0(eclipse/plugins/Axis2_Codegen_wizard_1.3.0)的名字改成Axis2_Codegen_wizard_1.4.0
在plugin.xml中在<plugin>中 把Axis2_Codegen_wizard的version="1.3.0"改成version="1.4.0"
到plugin.xml文件中,保存后重新启动Eclipse即可
3.开发过程
1.在spring的配置文件里加入:
<bean id= "applicationContext"class ="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
2.在axis2容器里的web.xml加入如下代码,用于加载spring的配置文件,用于初始化bean
So the implementaion will be; public String[] getRes(int a, int b) throws Exception { List list = new ArrayList(); list.add("ddd"); list.add("ddd"); list.add("ddd"); System.out.println(list); return (String[]) list.toArray(new String[list.size()]); } If the method signature returns collections, there is no way for Axis2 to figure out types of the items included in the list, hence you will get an error.