我正在使用ksoap和j2me。我将用户名和密码传递给asp.net Web服务方法,Web服务将数据集返回给我。我的问题是我怎么能 从这个ksoap响应(数据集)中获取“显示名称”元素?
<?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 :(得分:0)
您可以设置
envelope.implicitTypes = true
使用SoapObject方法导航Soap对象,如下所示:
SoapObject list = (SoapObject)response;
for(int i=0; i < list.getPropertyCount(); i++) {
SoapObject obj = (SoapObject)list.getProperty(i);