- 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();