3

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?

  • The point of today's Restful webservices is that they are schemless. They are not tied to rigid models and protocols. So if SOAP error propagation was good for you, you are free to adopt it and make it your own standar. Perphaps VoiceOfUnreason shared a very interesting link (the last one) – Laiv Oct 29 '16 at 16:14
2

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

  • Better call them "status codes". Whether a status is an error or not is often in the eye of the beholder. Even your link points to "status codes". – gnasher729 Oct 30 '16 at 12:51
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.

1

XML is supposed to be also possible, but I challenge a real use case...

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.