在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
有貓相伴的日子 閱讀(3794)
評論(4) 編輯 收藏 所屬分類:
webservices