我创建了一个以 DTO 作为参数的 Web 服务。 DTO 包含一个对象数组。
我已经生成了 WSDL、框架和客户端。
如果我传递字符串数组,我会尝试调用 Web 服务:
Serialized[] array = new String[] { "a", "n" };效果很好。
现在我的要求是传递 HashMap 数组,但我无法这样做,即使 HashMap 实现了可序列化。
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);
我正在使用Axis2。 2.1.5、Tomcat 6 和 Eclipse Helios。
我粘贴在这里供参考的堆栈跟踪。
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)
我正在使用Asix2开发一个项目,实际上我没有太多Axis2经验,HashMap是Java中的复杂对象,一些基础对象是由Asix2支持的,例如简单的Array,所以不要尝试使用Java的复杂对象你使用Axis。我认为你的要求无法得到,因为axis最近不支持它。谢谢和问候。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)