大概1年多前,有个项目用到webservice,那时候研究axis时候的一些记录,可以对比下现在的axis2或者xfire.
WebService之axis的复杂对象传输
<script language="javascript"><!----></script>
先自定义发布:
写一个deploy.wsdd 文件:
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="mShop" provider="java:RPC">
<parameter name="className" value="tests.shop"/>
<parameter name="allowedMethods" value="*"/>
<typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
qname="ns1:book"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
type="java:tests.book"
xmlns:ns1="http://127.0.0.1:8080/axis/services/mShop"/>
</service>
</deployment>
服务发布后,以上的发布信息都会被添加到server-config.wsdd文件里~
若服务发布出了什么问题(比如View里面看不到任何服务等……==!)一个考虑的就是这个server-config.wsdd~
上面的高亮显示,这是关键,它在server端定义如何序列化和反序列化complexType
若没有这个,那么你在客户端registry.getDefaultTypeMapping()将什么都得不到~~
这里的<typeMapping .../>定义了一个book对象,它是服务方法 public book[] getAllBooks() 的返回类型,类定义在tests.book,namespace是服务的namespace
具体的wsdd文件说明在axisUserguide里面,具体位置 : %axis_home%/docs/reference.html
以此类推,服务中所有的非原子类型返回都必须typeMapping一下~~~(= =!汗)
注册复杂类型的客户端代码:
org.apache.axis.client.Service service = new org.apache.axis.client.Service();
TypeMappingRegistry registry = service.getTypeMappingRegistry();
TypeMapping map = registry.getDefaultTypeMapping();
QName qType = new QName("http://localhost/tests","book");
Class qClass = Class.forName("tests.book");
map.register(qClass,qType,new BeanSerializerFactory(qClass, qType),
new BeanDeserializerFactory(qClass, qType));
要注意,Service是org.apache.axis.client.Service,而不是javax.xml.rpc.Service,如果用错了axis会发出一大堆http500来抱怨的~~~
附:自己写的一个类来远程调用axis的服务,省得一个个去service得call.
axisGo.rar (现在看来代码十分简陋,那时接触java还没半年。不过作为一个关键的螺丝已经运行在学校的xx系统里面了,真的是帮了我很大的忙,还写了个远程通过WEB服务访问数据库的orm工具,地狱一样的代码,到处是反射)
分享到:
相关推荐
Web服务框架 Apache Axis
资源名称:Apache Axis使用方法 (版本1.4)内容简介: Apache Axis是开源的SOAP服务器和客户端。SOAP是网络间不同语言的程序进行交互的方法。SOAP通常在HTTP上交换信息:客户端POST一个SOAP请求,然后接受HTTP响应,...
本部分是apache axis用户指南的第三部分。在Axis中使用WSDL文件。
org.apache.axis jar org.apache.axis jar org.apache.axis jar
Apache Axis2 Web Services 2nd Edition
基于java的开发源码-Web服务框架 Apache Axis.zip 基于java的开发源码-Web服务框架 Apache Axis.zip 基于java的开发源码-Web服务框架 Apache Axis.zip 基于java的开发源码-Web服务框架 Apache Axis.zip 基于java的...
包括3本Axis2的书(英文),實為2本(第1本有关于CXF(前身XFire)的内容為第三本的第三版) 1.Developing Web Services with Apache CXF and Axis2, 3rd Edition 2.Packt.Publishing.Quickstart.Apache.Axis2 3....
org.apache.axis2.jar
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 ...
APACHE AXIS2 。。。。。。。。。。。
Axis2快速指南,一本不错的小书,英文,解压缩之后是PDF格式。
Axis2在windows下的安装测试,主要是将配置、访问和管理
Extensive and detailed coverage of the enterprise ready Apache Axis2 Web Services / SOAP / WSDL engine. Attain a more flexible and extensible framework with the world class Axis2 architecture. Learn ...
apache 官网上下载的最新的axis2-1.7.9-bin.zip ,类型为Binary distribution
基于 Apache Axis2 将上述类的方法对外提供 Web 服务,生成 WSDL 文件,以及调用 服务 2019-12-23根据全网的教程搭建最详细的教程 源码太大上传不了,但是教程内容十分详细,跟着我的教程一步一步就可以搭建起来,...
关于WebService的实例及相关axis/apache-cxf的应用关于WebService的实例及相关axis/apache-cxf的应用
ApacheAxis系统架构及Axis设计基本原理.pdf
Tomcat_与_Apache_AXIS集成
axis2解决 org.apache.axis2.util.JavaUtils.callStackToString问题