How to be a good web service? Especially when things go wrong!
How to be a good web service? To be a good service means the service has good SLA with very little or no downtime, quick response to request, etc. In addition to these common knowledge, in my opinion, to be a good web service also means when something goes wrong, the service fail gracefully. Here are some negative examples.
I. Does not tell client that the service is wrong.
For example, when the service end point requires three mandatory parameters, the incoming request only contains two valid parameters. The service should return an error code with a detailed error message pinpointing the invalid parameter. Instead, it returns a valid response with 200 status code.
II. Gives too little error information.
Similar to scenario II. if the service returns a 400 bad request error, but doesn't tell client which parameter is invalid, it may takes some efforts for client to figure out which parameter is incorrect.
III. Gives incorrect/misleading error information.
Even worse, if the invalid parameter is parameter A, but the service reports that the incorrect parameter is parameter B, then this behavior may mislead the client.
IV. Gives too much private information.
Gives too much information is also bad. For example, some service may leak the stack trace or even authentication information to client when it cannot process the request correctly. This behavior sometimes can make the service an easy target for security attack.
If your web service can avoid the above pitfalls, your web service is qualified as a ethical web service.
Follow me at twttier