肥皂反应解析

时间:2012-06-27 09:44:33

标签: android soap xml-parsing

我已经复制了我在浏览器上获得的Soap响应,如何在Android中使用soap解析此响应? 我使用过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>

2 个答案:

答案 0 :(得分: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());

}

答案 1 :(得分:0)

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

相关问题