-2

我已经复制了我在浏览器上得到的 Soap 响应,我如何使用 soap 在 Android 中解析这个响应?我用过 SoapObject obj = (SoapObject)mySoapEnvelop.getResponse(); 但我得到 obj.getPropertyCount() = 1 。

我在这一点上很困惑,谁能帮我出来???

这是我的完整回复:

真的

<Data>
  <xs:schema id="NewDataSet" >
        <xs:element
            name="NewDataSet"
            msdata:IsDataSet="true"
            msdata:Locale="" >
            <xs:complexType>
                <xs:choice
                    maxOccurs="unbounded"
                    minOccurs="0" >
                    <xs:element name="Table" >
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element                     
                                    name="ID"
                                    minOccurs="0"
                                    type="xs:int" />
                                <xs:element
                                    name="UniqueID"
                                    minOccurs="0"
                                    type="xs:string"
                                    msdata:DataType="System.Guid, mscorlib,
           Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>        
                                <xs:element
                                    name="FullName"
                                    minOccurs="0"
                                    type="xs:string" />
                                <xs:element
                                    name="Title"
                                    minOccurs="0"
                                    type="xs:string" />
                                <xs:element
                                    name="Phone"
                                    minOccurs="0"
                                    type="xs:string" />
                               <xs:element
                                    name="Email"
                                    minOccurs="0"
                                    type="xs:string" />
                                <xs:element
                                    name="CreatedDate"
                                    minOccurs="0"
                                    type="xs:dateTime" />
                               <xs:element
                                    name="Website"
                                    minOccurs="0"
                                    type="xs:string" />
                               <xs:element
                                    name="CompanyName"
                                    minOccurs="0"
                                    type="xs:string" />
                                <xs:element
                                    name="LeadStatus"
                                    minOccurs="0"
                                    type="xs:string" />
                                <xs:element
                                    name="StatusName"
                                    minOccurs="0"
                                    type="xs:string" />
                                <xs:element
                                    name="IsRead"
                                    minOccurs="0"
                                    type="xs:boolean" />
                                <xs:element
                                    name="OwnerName"
                                    minOccurs="0"
                                    type="xs:string" />
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:choice>
            </xs:complexType>
        </xs:element>
    </xs:schema>

    <diffgr:diffgram>

        <NewDataSet>
           <Table
                diffgr:id="Table1"
                msdata:rowOrder="0" >
                <ID>6</ID>
                <UniqueID>8d93aab5-086f-41bb-b8ec-03b3eb0aa463</UniqueID>
                <FullName>bhatt</FullName>
                <Title />
                <Phone />
                <Email />
                <CreatedDate>2012-02-24T13:14:06.773+05:30</CreatedDate>
                <Website />
                <CompanyName>xyz</CompanyName>
                <LeadStatus>Qualified</LeadStatus>
                <StatusName>Approved</StatusName>
                <IsRead>false</IsRead>
                <OwnerName>Admin admin</OwnerName>
            </Table>
        </NewDataSet>
    </diffgr:diffgram>
</Data>

4

2 回答 2

1
SoapObject result = (SoapObject)envelope.bodyIn;

if(result != null){

    int count = result.getPropertyCount();
    //TextView t = (TextView)this.findViewById(R.id.resultbox);
    //t.setText("SOAP response:\n\n" + count);

    SoapObject nameResult = (SoapObject) result.getProperty(0);
    // TextView t = (TextView)this.findViewById(R.id.resultbox);
    //t.setText("SOAP response:\n\n" + nameResult.toString());

    SoapObject test = (SoapObject) nameResult.getProperty(1);
    // TextView t = (TextView)this.findViewById(R.id.resultbox);
    // t.setText("SOAP response:\n\n" + test.toString());

    SoapObject dar = (SoapObject) test.getProperty(0);
    //TextView t = (TextView)this.findViewById(R.id.resultbox);
    //t.setText("SOAP response:\n\n" + dar.toString());

    SoapObject suvas = (SoapObject) dar.getProperty(0);
    int c = dar.getPropertyCount();
    TextView t = (TextView)this.findViewById(R.id.resultbox);
    t.setText("SOAP response:\n\n" + suvas.toString());
    //t.setText("SOAP response:\n\n" + c);
    //SoapObject nivas = (SoapObject) suvas.getProperty(NewsId);
    //TextView t = (TextView)this.findViewById(R.id.resultbox);
    // t.setText("SOAP response:\n\n" + nivas.toString());

}
于 2013-09-04T09:47:31.053 回答
0

我认为您是编程新手。您无法解析此 xml 文件,因为这是 webservice 的服务描述。Webservice 将具有方法,在浏览器中单击这些方法,您将获得任何客户端都可以调用和解析的 xml 输出数据。另请参阅android/eclipse 中的此 Web 服务以解析您的数据。

于 2012-06-27T11:18:23.197 回答