I have the following XML data. How do I track the error tag in case of an invalid request or input?
If it is possible then can you please provide me proper code for this?
Login Request:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Signin xmlns="http://tempuri.org/">
<card_number> 123/321 </ card_number >
<dob>MM|DD|YYYY </dob >
</Signin>
</soap:Body>
</soap:Envelope>
Response:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SigninResponse xmlns="http://tempuri.org/">
<user>
<user_id>long</user_id>
<current_balance>string</current_balance>
<card_iamge><![CDATA[string]]></card_iamge>
</user>
</SigninResponse>
</soap:Body>
</soap:Envelope>
Transaction History Request:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TransactionHistory xmlns="http://tempuri.org/">
< user_id >1/2 </ user_id >
</TransactionHistory>
开发者_如何学C </soap:Body>
</soap:Envelope>
Response:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TransactionHistoryResponse xmlns="http://tempuri.org/">
<transactions>
<transaction>
<date><![CDATA[08/30/2010]]></date>
<amt>$10.50</amt>
<card>ASYU763543</card>
</transaction>
<transaction>
<date><![CDATA[08/30/2010]]></date>
<amt>$10.50</amt>
<card>ASYU763543</card>
</transaction>
<transaction>
<date><![CDATA[08/30/2010]]></date>
<amt>$10.50</amt>
<card>ASYU763543</card>
</transaction>
</transactions>
</TransactionHistoryResponse>
</soap:Body>
</soap:Envelope>
Error:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<*Response xmlns="http://tempuri.org/">
< error> string </ error >
</<*Response>
</soap:Body>
</soap:Envelope>
Have a look at this http://androidosbeginning.blogspot.com/2010/09/generic-xml-parsing-in-android.html
probably this could solve your problem.
精彩评论