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
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name> contextConfigLocation </param-name>
<param-value> /WEB-INF/applicationContext.xml </param-value>
</context-param>
3.目录结构:tomcat/axis2/WEB-INF
项目的配置文件都放在这里
修改配置文件里的一些内容:主要是加载路径相关,eg:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>/WEB-INF/hibernate.cfg.xml</value>
</property>
</bean>
4. 发布服务
aar包里在META-INF里面是
这个aar包里不需要放置类文件,只要一个services.xml用于标识将哪个类发布为服务
文件内容
<service name="student" >
<description>
Please Type your service description here
</description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name= "ServiceObjectSupplier" >
org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier
</parameter> //猜测是spring axis2 结合所需要的 类
<parameter name= "SpringBeanName" >studentservice</parameter>
//发布的服对应的类,因为是利用spring来加载,所以这里必须是spring 配置文件里对应的bean id
//而不能是类的绝对路径,因为需要spring的注入功能所以要从spring窗口里去取得类的实例
</service>
5.向axis2容器里添加项目的Lib包:
注:
axis2可能不支持List<T>这种集合类型,所以要使用对象数组类型来返回多个数据,或者利用String返回,将其在client端进行解析。
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.
这两天忽然对axis2来了兴趣, 于是下载来摆弄.
我没有直接在下载的axis2的war包的基础上去做, 而是一步一步把axis2添加到我原有的工程里面去, 这样做确实挺累人的, 不过网上已经很多这样的文章, 因此我不去写它了
我感兴趣的是, 怎么让axis能传输java对象, 其实也有文章介绍, 见
因为我原来的应用是struts2+spring+hibernate的, 便很自然的想把axis2的service整合到spring去, 结果却发现一个axis2的bug, 在axis2的论坛已经有人提过, 好像还没有修复.
如果你做一个Bean, 并让Spring为这个bean生成事务代理的JDK动态代理类, 那么, 启动应用的时候, 就报类似
org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: Unable to load bytecode for class $Proxy4
这样的出错信息, 很郁闷.
这意味着什么? 以为着我们公布的web service不能直接参与事务, 而是需要把事务"代理"给其他的类处理!!!
又多了一层不必要的封装!!!
我理想中的模型
Client ---------> ProxyTransactionalWebServiceBean
现在
Client----------> ProxyImpl ----------> ProxyTransactionalWebServiceBean
分享到:
相关推荐
今天特意将项目中用Axis2集成SSH实现WebService的过程记录下来,一方面做一下笔记,另一方面,方便广大码农朋友,希望能跟大家交流学习。 本文介绍用Axis2集成SSH搭建WebService。会达到的效果: 1.按照传统我们用...
Axis2与Eclipse整合开发的Web Service的服务端
axis2和已有web项目集成方法,axis2和已有web项目集成 axis2.war中的内容作为Web Project的基础, 来进行开发.
Axis2集成SSH搭建WebService支持事务,WebService服务还是挺多人用的
用axis2开发web service,过程比用axis1开发web service简单
基于AXIS2实现Web Service开发
二、 Web Service服务器端的发布。 2.1 创建java类。 2.2 创建services.xml。 2.3 发布服务。 2.4 在浏览器上测试服务。 三、 Web Service 客户端的创建。 3.1 创建WSDL文件。 3.2 利用WSDL创建stub。 3.3 利用stub...
Axis开发Web Service实例,介绍AXIS的三种方法
使用axis2与ssh整合开发webService文档与源码!其中包括客户端访问的lib包与源码demo
Axis2创建web service快速入门
java基于Axis2调用C#开发的web service获取xml结果
.Web Service简介 .如何开发一个Web Service .Axis2简介 .Axis2安装与部署 .Web Service开发步骤
Chapter 1, Apache Web Services and Axis2 - Gives you an introduction to web services and the web service stack at Apache. Chapter 2, Looking inside Axis2 - Learn about Axis2 architecture and the ...
web service Axis2相关jar 里面包含了Axis2 java调用.net接口所需jar包
axis发布webservice教程axis发布webservice教程axis发布webservice教程axis发布webservice教程
Web Service Axis2-1.6.2框架使用 压缩包里有:文档说明,axis2-1.6.2-bin.zip、axis2-1.6.2-war.zip、axis2-eclipse-codegen-plugin-1.6.2.zip、axis2-eclipse-service-plugin-1.6.2.zip。文档里用的所有jar压缩包...
WebService大讲堂之Axis2,Axis2教程,axis2教程例子,Web_Service实例应用
详细介绍axis2如何发布webservice
4.Add the DynamicResponseHandler module reference to the axis2.xml configuration (located in WEB-INF/conf): <module ref="DynamicResponseHandler"/> 5.Add the JSON Message formatters to the axis2....