本站不再更新,欢迎光临 java开发技术网
随笔-230  评论-230  文章-8  trackbacks-0
在WebServices的开发中,通常要处理处长复杂的类型,如返回的是Collection类,或参数是Collection类,或返回的是自定义对象类型,或者参数是自定义对象类型的类,都需要编写className.aegis.xml文件,这种处理方式与axis差不多一样,只不过axis是在service.wsdd中配置。
如有以下接口
package com.efs.xfire.pojo;

import java.util.*;

public interface CollectionsDemo {
    
public int getCollectionsRowCount(List list);
    
public List getUserList();
}

在该接口的同一包下,需进行如下配置
<?xml version="1.0" encoding="UTF-8"?>
<mappings>
    
<mapping>
        
<method name="getCollectionsRowCount">
            
<parameter index="0" componentType="java.lang.String"/>
        
</method>
        
<!-- 返回的类型是Map的话,做法和List一样。但定义的类型,是Map中的Value部分 -->
        
<method name="getUserList"> 
            
<return-type componentType="com.efs.xfire.entity.User"/>
        
</method>
    
</mapping>
</mappings>
只要是类中的方法返回类型或参数是对象类型(除java基本类型外或类集)都需要做相关的配置。

要作为WS发布的类务类,都需要在services.xml文件中作相应的配置
<beans xmlns="http://xfire.codehaus.org/config/1.0">
<service>
    
<name>HelloWorldService</name>
    
<namespace>http://efs.com/HelloWorldService</namespace>
    
<serviceClass>
        com.efs.xfire.pojo.HelloWorldService
    
</serviceClass>
    
<implementationClass>
        com.efs.xfire.pojo.HelloWorldServiceImpl
    
</implementationClass>
</service>

</beans>
posted on 2007-06-26 21:26 有猫相伴的日子 阅读(3770) 评论(4)  编辑  收藏 所属分类: webservices

评论:
# re: Xfire处理复杂类型的方法 2008-10-16 13:30 | ss
写清点好吧  回复  更多评论
  
# re: Xfire处理复杂类型的方法 2009-07-21 20:12 | xuyz
如果 Map中的对象是Map<String , List<InfoBean>>怎么设置?  回复  更多评论
  
# re: Xfire处理复杂类型的方法 2009-11-13 13:31 | bighorse
不就是book例子嘛,如果user里面又有list、map结构,你返回回来看看。  回复  更多评论
  
# re: Xfire处理复杂类型的方法 2013-05-21 16:46 | 周耀辉
@xuyz

把map转换成json

序列化后可先把map转换成list,在网络传输完成后在吧list转化成map  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
本站不再更新,欢迎光临 java开发技术网