问题
I have created a webservice which takes a DTO as a parameter. And DTO contains an array of objects. I've generated WSDL and skeletons and clients. I am trying to invoke the webservice if I pass array of Strings say : Serializable[] array = new String[] { "a", "n" }; it works fine.
Now my requirement is to pass array of HashMaps I am not able to do so, even though HashMap implements Serializable.
HashMap<String, String> hashMap1 = new HashMap<String, String>();
HashMap<String, String> hashMap2 = new HashMap<String, String>();
hashMap1.put("key1", "value1");
hashMap2.put("key1", "value1");
Serializable[] maps = new HashMap[] { hashMap1, hashMap2 };
myDTO.setParams(maps);
request.setDTO(myDTO);
InvokeServiceResponse response = stub.serviceMethod(request);
I am using Axis2. 2.1.5, Tomcat 6, and Eclipse Helios.
Stack trace I am pasting here for reference.
org.apache.axis2.AxisFault: Unknow type can not serialize
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)
at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
回答1:
I am using Asix2 to devolpe a project, actually I do not have Axis2 experience very much,HashMap is complex object in Java, some base objects are suppoeted by Asix2, such as simple Array, so do not try to use complex objects of Java when you use Axis.I think your reqest can not get, for axis recently do not support it.Thanks and regards.
回答2:
Look for a stack trace in the server logs; this is the client-side error.
Also, if you Google "Unknow type can not serialize" you will find many threads.
来源:https://stackoverflow.com/questions/6859844/org-apache-axis2-axisfault-unknow-type-can-not-serialize-while-passing-array-of