我拥有从WSDL2KSoap生成的所有类,并且我正常接收来自envelope.bodyIn的响应。我的envelope.bodyIn.toString()看起来像这样。
getCatResponse{
getCatResult=anyType{
returnCode=200;
category=anyType{
Category=anyType{
code=101;
name=Games;
};
Category=anyType{
code=102;
name=Apps;
};
};
};
}
如何从SoapObject中获取每一个。现在,我只能使用soapResult.getProperty(name)。我可以把它投射到我的getCatResponse.java吗?
答案 0 :(得分:0)
SoapObject soapResult = (SoapObject) result;
PropertyInfo pi = new PropertyInfo();
soapResult.getPropertyInfo(0, pi);
SoapObject soapResult2 = (SoapObject) pi.getValue();
PropertyInfo pi2 = new PropertyInfo();
soapResult2.getPropertyInfo(2, pi2);
SoapObject soapResult3 = (SoapObject) pi2.getValue();
PropertyInfo pi3 = new PropertyInfo();
soapResult3.getPropertyInfo(0, pi3);
Log.i(LOG, pi3.toString());
哦,使用getPropertyInfo。你会从上面的代码中得到这个
Category=anyType{
code=101;
name=Games;
};