如何解析返回List <list <string>&gt;的wcf ksoap2响应机器人</列表<字符串>

时间:2014-02-10 12:47:06

标签: c# android wcf android-ksoap2 arrayofstring

我有一个返回List&gt;的wcf ksoap2服务作为回应。现在我必须解析这个回复

anyType

{

ArrayOfstring=anyType

{
string=Wireless; string=Access Wireless; string=anyType{}; string=anyType{}; string=00001; string=--;
};

ArrayOfstring=anyType
{
string=Wireless; string=Airlink; string=anyType{}; string=anyType{}; string=00003; string=--;
};

ArrayOfstring=anyType
{
string=Long Distance; string=Nobel LD GOT Africa; string=anyType{}; string=anyType{}; string=NBLDAF; string=--;
};

ArrayOfstring=anyType
{
string=Long Distance; string=STI LD Smash; string=anyType{}; string=anyType{}; string=00028; string=--;
};

ArrayOfstring=anyType
{
string=International TopUp; string=Afghanistan Etisalat Top-Up $2-$75; string=Hussain; string=0345339; string=ETIAFG; string=--;
};

ArrayOfstring=anyType
{
string=International TopUp; string=Afghanistan Etisalat Top-Up $2-$75; string=Hussain; string=0345339; string=ETIAFG; string=--;
}; 

ArrayOfstring=anyType
{
string=International TopUp; string=Bolivia Viva Top-Up $5 - $75; string=Hussain; string=0345339; string=VIVABO; string=--; 
}; 

ArrayOfstring=anyType
{
string=International TopUp; string=Bolivia Viva Top-Up $5 - $75; string=Hussain; string=0345339; string=VIVABO; string=--; 
}; 

ArrayOfstring=anyType
{
string=International TopUp; string=Peru Movistar Top-Up  $5 - $75; string=Hussain; string=0345339; string=anyType{}; string=--;
};

}

我知道如何解析返回List的响应。我正在使用此代码

HttpTransportSE htp = new HttpTransportSE(URL);

            htp.call(SOAP_ACTION, soapEnvelop);

            response = (SoapObject) soapEnvelop.getResponse();

            if (response != null) {

                if (response.getPropertyCount() > 0) {
                    InternationalTopup.arr_Items = new String[response
                            .getPropertyCount()];
                    for (int i = 0; i < response.getPropertyCount(); i++) {
                        InternationalTopup.arr_Items[i] = response.getProperty(
                                i).toString();

                    }
                }
            }

但我不知道如何解析上面的回复。 我必须使用Json吗? 请提供一些示例并分享您的经验。 任何帮助将不胜感激。感谢

1 个答案:

答案 0 :(得分:0)

如果您在WCF上构建服务并且可以返回json,那么您不需要使用KSoap。在我的博客中有一个详细的例子。 Please refer this