Error message from POST web service

I am developing a web service (in asp.net), and I would like every web method report to call it when an internal error has occurred - for example, when input validation fails.

When I expose my web service using SOAP, such errors can be reported by throwing a SoapException. But what if I expose my web service using a simple POST (aka Http-Post)? Besides returning an HTTP status code with an error of 500, is there a standard for reporting errors or throwing exceptions in this case?

+4
source share
2 answers

Modify the response object so that it contains the registered state and error message (or just an error message and check in the receiver if it is empty) and set it correctly, instead of throwing an exception.

+2
source

I always returned a 500 status code along with a textual description of the error. Just make sure it is documented so that the client can handle it correctly.

+1
source

All Articles