[英]Android Ksoap get a list array of class from webservice
我正在開發一個Android應用程序以從wevservice獲取類列表
Web服務的方法類似於List<mytable> GetAllmytableData();
但是我無法在mytable類中投射這些數據。 我創建了一個mytable類,如http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html此鏈接建議。 還在myclass中應用了kvm序列化來投射數據。 但總是會得到java.lang.ClassCastException: org.ksoap2.serialization.SoapObject
錯誤。
我進入soapenvelope的數據就像
anyType{DisplayName=a; Email=hi@y.com; FirstName=a; LastChangedDate=2/5/2012 11:24:38 PM; LastName=a; ObserverID=1; UserID=1; }
anyType{DisplayName=b; Email=hi@y.com; FirstName=b; LastChangedDate=2/5/2012 11:25:52 PM; LastName=b; ObserverID=1; UserID=2; }
anyType{DisplayName=c; Email=hi@y.com; FirstName=c; LastChangedDate=2/6/2012 9:10:44 AM; LastName=c; ObserverID=3; UserID=3; }
我如何解析並放入“ mytable”類的對象數組,
關於提供的鏈接plz的任何建議
Kishor,這是一個多維數組,采用第一個數組:
anyType//property 0
{
DisplayName=a; // property 0 [0]
Email=hi@y.com; // 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] ;
等等...如果你想在這里查看我的答案
嘗試使用數組而不是列表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.