Android - How to convert SoapPrimitive result into an string array in android

1.3k Views Asked by At
I have following method that returns a string array in asp.net Webservice



[WebMethod]
public String[] findfactors(int x)
{
   String[] facts = new String[2]; 

   facts[0] = "jhj";
   facts[1] = "hgfh";    

   return facts; /// I am returning the string array from the asp.net web service
}

Now I want to get the result variable of SoapPrimitive in an array string of ANDROID JAVA. I have tried to do it like the following way but I receive an error

String array_test=new String [2];
for (int i=0;i<2;i++)
{
  arraytest[i]=result[i]; // I am assigning the result to my string array

}
1

There are 1 best solutions below

0
On

Once you have the SoapResult as SoapPrimitive, you have to unmarshall it like this:

SoapObject obj =(SoapObject) SoapResult.getProperty(0);
//fetch all the row of the Soap result
for(int i=0; i<obj.getPropertyCount(); i++)
{
   String string= obj.getProperty(i).toString();
   //Do what you want
}