首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

webservice调用怎么返回一个List包含List的复合对象

2012-01-20 
webservice调用如何返回一个List包含List的复合对象Java codepackage com.dataExchange.webserviceClient

webservice调用如何返回一个List包含List的复合对象

Java code
package com.dataExchange.webserviceClient;import java.net.URL;import org.codehaus.xfire.client.Client;public class GetLogListServiceClient {        public static void main(String[] args) throws Exception{        System.out.println(new GetLogListServiceClient().getLogList());    }    public Object getLogList() throws Exception {        Client client = new Client(new URL("http://192.168.1.6:8080/DataExchange2/services/XmlDataProvider?wsdl"));        Object[] paraArr = new Object[]{1};        Object[] results = client.invoke("updateLogDispEntries", paraArr);                return (Object)results[0];    }}


以上所调用的方法是updateLogDispEntries 它更新数据库并且以List包含List的对象形式返回数据库所有数据 
单独运行该方法完全没问题 但通过webservice执行以上程序后 发现数据库是更新了 但返回值却没有 是[#document: null] 换了用Object数组装数据也是同样的结果


[解决办法]
换一种动态调用方式
Java code
Service serviceModel = new ObjectServiceFactory().create(XmlDataProvider.class);     XmlDataProvider service = (XmlDataProvider) new XFireProxyFactory().create(serviceModel,"http://localhost:8080/Test/services/XmlDataProvider");          List<String> list = service.getList(); 

热点排行