2011-12-29 58 views
1

我正在使用j2me的ksoap。我將用戶名和密碼傳遞給asp.net web服務方法,Web服務將數據集返回給我。我的問題是我如何從這個ksoap響應(數據集)獲取「顯示名稱」元素?j2me和ksoap如何獲得asp.net webservice中的特定元素

<?xml version="1.0" encoding="utf-8" ?> 
    - <DataSet xmlns="http://tempuri.org/"> 
    - <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> 
    - <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> 
    - <xs:complexType> 
    - <xs:choice minOccurs="0" maxOccurs="unbounded"> 
    - <xs:element name="Users"> 
    - <xs:complexType> 
    - <xs:sequence> 
     <xs:element name="Userid" type="xs:string" minOccurs="0" /> 
     <xs:element name="Password" type="xs:string" minOccurs="0" /> 
     <xs:element name="DisplayName" type="xs:string" minOccurs="0" /> 
     <xs:element name="Role" type="xs:string" minOccurs="0" /> 
     <xs:element name="Status" type="xs:string" minOccurs="0" /> 
     <xs:element name="SessionId" type="xs:string" minOccurs="0" /> 
     </xs:sequence> 
     </xs:complexType> 
    </xs:element> 
- <xs:element name="UserAccess"> 
- <xs:complexType> 
- <xs:sequence> 
    <xs:element name="Refno" type="xs:long" minOccurs="0" /> 
    <xs:element name="UserId" type="xs:string" minOccurs="0" /> 
    <xs:element name="MenuId" type="xs:string" minOccurs="0" /> 
    <xs:element name="Control" type="xs:string" minOccurs="0" /> 
    </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
    </xs:choice> 
    </xs:complexType> 
    </xs:element> 
    </xs:schema> 
    </DataSet> 
+0

如果任何人能回答這個問題,我可以使用相同的模式進行的Andriod ! – 2011-12-29 07:17:45

回答

0

可以使用SoapObject方法,這樣設置

envelope.implicitTypes = true 

和導航肥皂對象:

SoapObject list = (SoapObject)response; 

for(int i=0; i < list.getPropertyCount(); i++) { 
    SoapObject obj = (SoapObject)list.getProperty(i);