2012-02-09 119 views
0

獲取類的列表陣列我正在開發一個Android應用程序從wevservice的Android KSOAP從web服務

Web服務的方法是像List<mytable> GetAllmytableData();獲取類的列表,但我不能投在我的mytable的類數據。我創建了一個mytable類,如http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html這個鏈接建議。 也應用kvm序列化在myclass中投射數據。但總是得到java.lang.ClassCastException: org.ksoap2.serialization.SoapObject錯誤。

數據我得到的的SoapEnvelope就像

anyType{DisplayName=a; [email protected]; FirstName=a; LastChangedDate=2/5/2012 11:24:38 PM; LastName=a; ObserverID=1; UserID=1; } 
anyType{DisplayName=b; [email protected]; FirstName=b; LastChangedDate=2/5/2012 11:25:52 PM; LastName=b; ObserverID=1; UserID=2; } 
anyType{DisplayName=c; [email protected]; FirstName=c; LastChangedDate=2/6/2012 9:10:44 AM; LastName=c; ObserverID=3; UserID=3; } 

我怎麼可以解析並把我的「mytable的」類的對象數組,

上的鏈接PLZ任何建議提供

回答

2

基肖爾,這是一個多維數組佔據第一位:

anyType//property 0 
{ 
DisplayName=a; // property 0 [0] 
[email protected]; // property 0 [1] 
FirstName=a; // property 0 [2] 
LastChangedDate=2/5/2012 11:24:38 PM; //etc... 
LastName=a; 
ObserverID=1; 
UserID=1; 
} 

可以手動獲取每個屬性這樣的:

SoapObject yourResponseObject = (SoapObject) soapEnvelope.bodyIn; 
SoapObject array = (SoapObject) yourResponseObject .getProperty(0);// this is -->anyType //property 0   

SoapObject DisplayName= (SoapObject)array .getProperty(0);// this is--> // property 0 [0] ; 
SoapObject Email= (SoapObject)array .getProperty(1);// this is--> // property 0 [1] ; 

等.. 此外,如果你想查詢我的回答here

1

嘗試使用數組而不是List。

相關問題