Handling a SoapException
-
Hi, I call a web service method and if it fails I get a load of Soap error stuff that I don't want: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: MyErrorMsgString. at MyWebService.TestThrowException() --- End of inner exception stack trace --- How can I get it to just display the error message I want? In the stuff above I just want to get the MyErrorMsgString text. Thanks :)
-
Hi, I call a web service method and if it fails I get a load of Soap error stuff that I don't want: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: MyErrorMsgString. at MyWebService.TestThrowException() --- End of inner exception stack trace --- How can I get it to just display the error message I want? In the stuff above I just want to get the MyErrorMsgString text. Thanks :)
-
The InnerException property of the SOAP exception contains the exception from the server.
Experience is the sum of all the mistakes you have done.
Thanks for replying :) The message shows the inner exception though - it has all that extra text around it and that's what I don't want. It seems that when I get an error message back from a web service I've written, it contains all that extra stuff. I just want it to send back the error text I provide not all that other stuff.
-
Thanks for replying :) The message shows the inner exception though - it has all that extra text around it and that's what I don't want. It seems that when I get an error message back from a web service I've written, it contains all that extra stuff. I just want it to send back the error text I provide not all that other stuff.
Make sure your web service is throwing an actual
SoapException
rather than just anException
. You can throw one as easily as this:throw new SoapException("My Error Text", SoapException.ClientFaultCode);
You'll get a more "concise" message that way. For more general information see here[^].
Evil cannot be conquered in the world... It can only be resisted within oneself.
-
Thanks for replying :) The message shows the inner exception though - it has all that extra text around it and that's what I don't want. It seems that when I get an error message back from a web service I've written, it contains all that extra stuff. I just want it to send back the error text I provide not all that other stuff.