2

我正在使用 KSOAP2 for Android 调用基于 Java 的 Web 服务,我想知道如何使用 KSOAP 故障消息。

例如:响应转储看起来像这样:

<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==============================Column : [NAME] doesn't exist</SQLError>
    <ErrorCode>0</ErrorCode>
    </ns2:SQLException>
   </detail>
  </soap:Fault>
 </soap:Body>
</soap:Envelope>

如何将“[Name] 不退出”错误转发给应用程序?

4

1 回答 1

1

信封.getResponse 将抛出您刚刚捕获的 SoapFault 异常,然后使用 getMessage 调出 toast 或您想做的任何事情。

于 2011-09-08T21:15:50.943 回答