Android - 如何将SoapPrimitive结果转换为android中的字符串数组

时间:2013-12-08 23:31:44

标签: android asp.net arrays web-services ksoap2

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
}

现在我想在ANDROID JAVA的数组字符串中获取result的{​​{1}}变量。我尝试过以下方式,但收到错误

SoapPrimitive

1 个答案:

答案 0 :(得分:0)

一旦你将SoapResult作为SoapPrimitive,你就必须解开它:

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
}