1
我正在研究一個利用我的Web服務獲取數據並顯示它的android應用程序。我的SOAP響應有點複雜,看起來像這樣。解析SOAP響應中的非法屬性錯誤
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetSessionDetailsResponse xmlns="https://viberservices.com/gcdev/">
<GetSessionDetailsResult>
<ModuleFlags>string</ModuleFlags>
<SessionID>string</SessionID>
<UserInfo>
<Fullname>string</Fullname>
<Language>long</Language>
</UserInfo>
<Locations>
<LocationDetails>
<LocationID>long</LocationID>
<LocationName>string</LocationName>
<PhotoURL>string</PhotoURL>
</LocationDetails>
<LocationDetails>
<LocationID>long</LocationID>
<LocationName>string</LocationName>
<PhotoURL>string</PhotoURL>
</LocationDetails>
</Locations>
</GetSessionDetailsResult>
</GetSessionDetailsResponse>
現在我想從位置部分的位置ID和地點名稱的數據。我正在使用下面的代碼。
SoapObject res=(SoapObject)envelope.bodyIn;
SoapObject t=(SoapObject)res.getProperty("Locations");
for(int i=0; i<t.getPropertyCount(); i++){
SoapObject locinfo=(SoapObject)t.getProperty(i);
String lid= locinfo.getProperty("LocationID").toString();
String lname= locinfo.getProperty("LocationName").toString();
}
//Code to display lid and lname
但我得到一個運行時異常說了java.lang.RuntimeException:非法財物:位置