I’m developing a web service (in asp.net) and I would like to have each web method report to whoever called it when an internal error occurs – for example when input validation has failed.
When I expose my web service with SOAP such errors can be reported by raising a SoapException. But what if I expose my web service with plain POST (aka Http-Post)? Other than returning a 500 Error HTTP status code, is there a standard for reporting errors or raising exceptions in this case?
Change the response object to contain a status filed, and error message (or only error message, and check at the receiver if empty), and set it properly instead of throwing an exception.