입력 조건이 잘못된 경우 예외가 발생하는 ASP.NET WebService
이 있습니다.안드로이드 ksoap2 ASP.NET 예외 처리
다른 C#/ASP.NET 응용 프로그램 클라이언트에서 호출하는 경우 예외를 올바르게 해석 할 수 있습니다.
그러나 ksoap2가 호출하는 경우 대신 HTTP 상태 500이 표시됩니다.
내가이 예외를 처리하는 가장 좋은 방법은 무엇인지 알 수 있으며 가장 중요한 것은 사용자에게 표시 할 수 있도록 해당 예외 내의 오류 메시지를 검색하는 것입니다.
미리 감사드립니다.
ASP.NET 웹 서비스
이[WebMethod]
public void Test()
{
throw new Exception("This is a test message");
}
// 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();
}
기본적으로 '응답 코드'입니다. '404,500,403'인지 여부를 확인할 수 있으며,이를 토스트 나 무언가를 보여줄 수 있습니다. – Prateek
예, 응답 코드 505 만 있습니다.하지만 사실 SOAP 오류에는 메시지가 있습니다. ASPNET 클라이언트는 특정 메시지를 검색 할 수 있습니다. 그러나 ksoap2 클라이언트는 그렇지 않습니다. –