Tag Archives: ksoap

How to process an array returned by a wsdl – Android

I saw many questions being asked on how to process an array returned by a wsdl, even I had the same problem when I had to retrieve an array from wsdl to android.

So here I would like to share how I retrieved the array and how I have processed it to create it as an array inside Android.

String r = NameArray.columncount("userid", limitstart, loadNumber,loggername);
String temp = r.replaceAll(";\\s", ",").replaceAll("string=", " ")
.replace("anyType{", "").replace(",}", "");
String[] fulname = temp.split(",\\s+");

‘NameArray.columncount’ is my function which gets the array from the wsdl(don’t get confused in that)

step 1- Here I am getting the array values returned from the wsdl in to a string called ‘r’.In this case I am getting an array of numbers Returned array string r looks like this

r ="anyType{string=10054; string=10055; string=10056; string=10035; string=10052; string=10036; string=10037; string=10038; }"

step 2- Then creating a String variable called temp where I am removing all the unwanted characters using the replaceAll function. after removing unwanted characters temp looks like this

temp="10054, 10055, 10056, 10035, 10052, 10036, 10037, 10038"

step3- Finally created a string array called ‘fulname’ and split the modified string with ‘,\s’ Array fulname after split looks like this

fulname = [ 10054, 10055, 10056, 10035, 10052, 10036, 10037, 10038]

This will work fine because all the wsdl array return the same type of string with same unwanted characters

Hope you understood
Good Luck