我有多维数组的问题,我在soap中有web服务,需要将此数组作为参数传递,如下所示:
HashMap<String, String> phone = new HashMap<String, String>();
phone.put("internalId", "phone");
phone.put("fieldId", "8");
phone.put("displayName", "Phone");
phone.put("value", "XXXXXXXXXXXX");
custom_field.add(phone);
/*Log.d("hash Phone", String.valueOf(phone));
Log.d("hash Phone custom Field ", String.valueOf(custom_field));*/
HashMap<String, String> address = new HashMap<String, String>();
address.put("internalId", "address");
address.put("fieldId", "3");
address.put("displayName", "Address");
address.put("value", " XXXX XXXXX, XXXX");
custom_field.add(address);
/*Log.d("hash Address", String.valueOf(phone));
Log.d("hash Address custom Field ", String.valueOf(custom_field));*/
HashMap<String, String> nationalid = new HashMap<String, String>();
nationalid.put("internalId", "nationalid");
nationalid.put("fieldId", "13");
nationalid.put("displayName", "National-ID");
nationalid.put("value", "XXXXXXX");
custom_field.add(nationalid);
HashMap<String, String> maritalstatus = new HashMap<String, String>();
maritalstatus.put("internalId", "maritalstatus");
maritalstatus.put("fieldId", "16");
maritalstatus.put("displayName", "Marital status");
maritalstatus.put("value", "Single");
custom_field.add(maritalstatus);
我想像下面的示例PHP数组一样传递数组:
Array
(
[0] => Array
(
[internalId] => phone
[fieldId] => 8
[displayName] => Phone
[value] => XXXXXXXXX
)
[1] => Array
(
[internalId] => address
[fieldId] => 3
[displayName] => Address
[value] => XXXX XXXXX, XXXX
)
[2] => Array
(
[internalId] => nationalid
[fieldId] => 13
[displayName] => National-ID
[value] => XXXXXXX
)
[3] => Array
(
[internalId] => maritalstatus
[fieldId] => 16
[displayName] => Marital status
[value] => Single
)
)
并将soapfault错误视为错误,如
java.lang.RuntimeException: Cannot serialize:
任何帮助如何通过android完成此任务。
我已尝试过hashmap嵌套以及arraylist嵌套,但它们都没有为我工作。