How to use KSOAP fault-messages
I'm invoking a Java-based web-service with KSOAP2 for Android, and I would like to know how I can make use of the KSOAP fault-messages.
For example: The response-dump looks like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body><soap:Fault>
<faultcode>soap:Server</faultcode><faultstring>SQL Error</faultstring>
<detail>
<ns2:SQLException xmlns:ns2="http://...">
<SQLError>[PreferenceException]Error compiling sql-expression========================开发者_StackOverflow社区======Column : [NAME] doesn't exist</SQLError>
<ErrorCode>0</ErrorCode>
</ns2:SQLException>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
How can I forward the "[Name] doesn't exit"-error to the application?
envelope.getResponse will throw a SoapFault exception that you just catch and then use getMessage to bring up a toast or whatever you want to do.
精彩评论