-2

I have copied the Soap response which i am getting on the browser, How can i parse this response in Android using soap? I have used SoapObject obj = (SoapObject)mySoapEnvelop.getResponse(); But I am getting obj.getPropertyCount() = 1 .

I am confused at this point can any one help me to come out ???

Here is my complete response :

true

<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>

Rohit
  • 1
  • 6
  • You can either use SAX/DOM parser to parse the response. There are many tutorials for the same. – AndroGeek Jun 27 '12 at 09:57
  • You should edit the question to fix the code display. I have tried twice but for some reason my edits keep getting rejected? – olly_uk Jun 27 '12 at 10:05
  • i have just copied whole xml response which I have got on the browser. I dont know why it seen not proper at here. – Rohit Jun 27 '12 at 10:55

2 Answers2

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());

}
  • can u help to answer this question ? http://stackoverflow.com/questions/26903238/how-to-parse-soap-response-when-child-tags-have-different-name-and-no-of-tag-are –  Nov 13 '14 at 07:25
0

I think you are novice in programming.You can not parse this xml file because this is service description of webservice.Webservice would have methods,click on these methods in your browser and you will get xml output data which any client can call and parse. See also this web service in android/eclipse to parse your data.

Community
  • 1
  • 1
himanshu
  • 1,990
  • 3
  • 18
  • 36
  • Hi to all I have successfully parse the Complex SOAP response without using xml parser.... – Rohit Jun 30 '12 at 06:58