序列化整数数组使用KSOAP2送 [英] Serialize an array of ints to send using KSOAP2
问题描述
我有一个问题,试图发送int数组到预计的其中一个参数数组.NET Web服务。这至少是我从Web服务的API描述,说这明白了:
I'm having a problem trying to send an array of ints to a .NET web service which expects an array in one of the arguments. That's at least what I understand from the API description on the web service which says this:
<dataIndexIDs>
<int>int</int>
<int>int</int> </dataIndexIDs>
所以,当我把一个单个int像下面我没有得到任何错误,我觉得它工作得很好。
So when I send a single int like below I do not get any errors and I think it works fine.
request.addProperty("dataIndexIDs", 63);
但是,当我尝试发送int数组:
But when I try to send an array of ints:
request.addProperty("dataIndexIDs", new int[] {63, 62}); // array of ints
或整数ArrayList的:
or a ArrayList of Integers:
ArrayList<Integer> indexes = new ArrayList<Integer>();
indexes.add(63);
indexes.add(62);
request.addProperty("dataIndexIDs", indexes); // ArrayList of Integers
我抛出一个了java.lang.RuntimeException:无法序列异常。任何帮助吗?我究竟做错了什么?谢谢!
I get thrown a "java.lang.RuntimeException: Cannot serialize" exception. Any help please? What am I doing wrong? Thanks!
推荐答案
这是一个已知的问题与KSOAP2为Android库,这在目前根本不支持数组。这个问题的描述是在这里:
It is a known issue with the KSOAP2 for Android library, which at the moment simply does not support arrays. The issue description is here:
的http:// code。 google.com/p/ksoap2-android/issues/detail?id=19
一个第三方补丁,解决方案和示例可以在这里找到:
A third-party patch, solution and an example can be found here:
http://people.unica.it/bart/ksoap2-patch/
我个人还没有测试过任何人,因为他们也需要改变Web服务的WSDL,但显然他们解决这个问题。
I personally haven't tested any of them as they require also changing the web service WSDL but apparently they address the issue.
这篇关于序列化整数数组使用KSOAP2送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!