SOAP has a standard way of propagating errors, a SOAPFault field in the envelope. This standard also implies a number of things, such as its structure.
RESTful, being an application style, implies much less on how errors should be propagated. There’s no concept of an envelope and more and more I believe that the services contract are supposed to be as simple as possible, a very straightforward JSON structure (oh, XML is supposed to be also possible, but I challenge a real use case…).
That being said, simple doesn’t mean incomplete or weak. But I can’t seem to find a good guidance on how to do this – and worse, it seems to me every API defines it’s own way of doing it, resulting in a very heterogenic, savage even, environment.
TL;DR Is there a standard governing RESTful services (even if only proposed) that would give me any guidance with error propagation?
1
Restful is based on the different HTTP request methods GET POST PUT and DELETE
Therefore HTTP Error codes are how you can respond to Errors.
http://www.restapitutorial.com/httpstatuscodes.html
1
I have a good amount of experience with SOAP and IMO there is much more standardization around errors in HTTP than with SOAP/WSDL. Start with this list of error codes and this list of error codes.
I will say that the standard set of error codes is not extremely expressive and that may be leading to the lack of consistency across what you see. I think this is probably one of the main weaknesses in RESTful approaches. On the other hand, SOAP doesn’t really provide much of a standard either. It just gives you a few elements and lets you put whatever you want in the details.
You can absolutely return XML from a RESTful service. The frameworks that I’ve seen make it quite trivial. Actually, you can return SOAP from a a restful service. I’ve seen serivces that accept SOAP requests and return JSON (not really RESTful but built on a rest framework.) You say you are looking for a use case but I think you mean example. XML is unpopular so not many people bother anymore with it.
XML is supposed to be also possible, but I challenge a real use case…
- https://www.rfc-editor.org/rfc/rfc4287
- https://www.rfc-editor.org/rfc/rfc5023
Is there a standard governing RESTful services (even if only proposed) that would give me any guidance with error propagation?
You might be looking for application/problem-json.