日期:2014-05-17  浏览次数:20768 次

关于Axis2传回ArrayList的问题
我正在学习web service想传一个ArrayList给客户端但报错请教
service class如下:
Java code

public class ReturnArrayList {
    public ArrayList sayHelloArray(String user){
        ArrayList al = new ArrayList();
        al.add("str01");
        al.add("str02");
        al.add("str02");
        al.add("str02");
        return al;
    }
}


用eclipse发布成web service没问题
再使用eclipse -> Axis2 Code Generator产生client如下:
Axis2ArrayListTest.java
Axis2ArrayListTestCallbackHandler.java
Axis2ArrayListTestStub.java
ExtensionMapper.java
SayHelloArray.java
SayHelloArrayResponse.java
自己写的如下:
Java code

public class testAxis2ArrayListClient {
    public static void main(String[] args) {
        try {
            Axis2ArrayListTest a2t = new Axis2ArrayListTestStub();
            SayHelloArray sayHelloArray = new SayHelloArray();
            sayHelloArray.setUser("Garrick");
            SayHelloArrayResponse response = a2t.sayHelloArray(sayHelloArray);
            ArrayList al = (ArrayList) response.get_return();
            Iterator it = al.iterator();
            while(it.hasNext()){
                System.out.println(it.next());
            }
        } catch (AxisFault e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        
    }
}



产生错误如下:
Java code

org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Any type element type has not been given
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at axisarray.Axis2ArrayListTestStub.fromOM(Axis2ArrayListTestStub.java:514)
    at axisarray.Axis2ArrayListTestStub.sayHelloArray(Axis2ArrayListTestStub.java:193)
    at testWebService.testAxis2ArrayListClient.main(testAxis2ArrayListClient.java:24)
Caused by: java.lang.Exception: org.apache.axis2.databinding.ADBException: Any type element type has not been given
    at axisarray.SayHelloArrayResponse$Factory.parse(SayHelloArrayResponse.java:447)
    at axisarray.Axis2ArrayListTestStub.fromOM(Axis2ArrayListTestStub.java:508)
    ... 2 more
Caused by: org.apache.axis2.databinding.ADBException: Any type element type has not been given
    at org.apache.axis2.databinding.utils.ConverterUtil.getAnyTypeObject(ConverterUtil.java:1649)
    at axisarray.SayHelloArrayResponse$Factory.parse(SayHelloArrayResponse.java:425)
    ... 3 more




------解决方案--------------------
我只知道错误信息大概是两边类型不对应问题,,具体没玩过WEBSERVICE= =