WebService
入力条件が間違っている場合に例外をスローする ASP.NETがあります。
別の C# / ASP.NET アプリケーション クライアントによって呼び出された場合、それらは例外を正しく解釈できます。
しかし、ksoap2 によって呼び出されると、代わりに HTTP ステータス 500 が返されます。
この例外を処理する最善の方法を教えてください。最も重要なのは、その例外内のエラー メッセージを取得して、ユーザーに表示できるようにすることです。
前もって感謝します。
---- 以下のコードを追加します。
ASP.NET Web サービス
[WebMethod]
public void Test()
{
throw new Exception("This is a test message");
}
Android ksoap2 クライアント
// There are some details been obmitted. Just assume the code below works ok?
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, 60000);
try
{
// The Web Service in ASPNET is invoked successfully. And an Exception is thrown.
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject obj;
obj = (SoapObject)envelope.getResponse();
}
catch (Exception e)
{
// Manage to reach here. But How can I retrieve the Fault Message "This is a test message"?
e.printStackTrace();
}