Thanks for this good article.
You may also need to consider what language the end user needs the message in. I have seen too many systems that just pass an English error message from a web service on to a user who does not speak English.
If the web service sends the error message back in the end users language, you should have a short error code before the message text. For example ‘E001 username is missing’.
Without a standard code for each error, looking through log files with messages in lots of languages for a problem is horrible, but that is easy compared with trying to program around a response that could be in one of six languages that you do not speak.