I have a web method that returns a String[][] and I’m trying to parse the return in ksoap2 in android. I can’t seem to understand how it is serialized, but all I’m trying to do is to get the return in a String[][] or ArrayList or Vector or any data structure. I’v tried them all and nothing seems to work. Here is my code.
try
{
// connect to web service and call getUploadedMonthsYears web method
request = new SoapObject(NAMESPACE, "getUploadedMonthsYears");
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.call("http://alfaisaliah.com/getUploadedMonthsYears", envelope);
// create a serializable object that will hold the array of strings
ks = (KvmSerializable)envelope.bodyIn;
monthsYears = new String[10][10];
for(int i = 0; i < ks.getPropertyCount(); i++)
{
monthsYears[i][i] = ks.getProperty(i).toString();
}
} catch (Exception ex)
{
System.out.println(ex.getMessage());
return;
}
the getUploadedMonthsYears() web method returns a String[][] as follows
month, year
1, 2011
2, 2011
3, 2011
1, 2012
and so on. thanx
I have a similar web service (Axis2) that returns a matrix of strings:
It’s an 3×2 matrix of strings. It’s not a valid JSON response so I use some hack to split the response.
Try this:
This works for me, but I think that only works for primitive types included String.
Hope it helps.