Is there any way to catch the HTTP 500 error returned by the .asmx web service from the client. Net?
Using .Net 4.5 (VS2015), the .Net client code consumes the .asmx web service and calls it using the following code:
var client = new WebserviceApi.MyServiceSoapClient(); var response = client.MyWebServiceMethod();
If the .asmx web service returns an HTTP 500 error with a SOAP message containing the error message data, the response variable is set to null.
Using Fiddler, traffic shows an HTTP 500 response from the .asmx web service. The response contains an XML SOAP message with detailed error information.
No exception is thrown or gets into the client code .Net, execution continues as usual.
This means that the client cannot obtain information about the nature of the exception. All client code can check if the "response" is null, but the exception message is not available for the client code.
Is there a way to make the .Net client code throw an exception if the .asmx web service returns an HTTP 500 response so that I can check / log the error message?
Lenny source share