views:

9

answers:

1

I am developing some SOAP web services using Ruby on Rails and considering how to handle generic failures. These generic errors are applicable to all the methods within the service and include the following :-

  • Missing Request element
  • Missing Authentication element (Custom)
  • Invalid Authentication details

I can intercept these errors within my controller before calling the relevant method and respond appropriately. My question is which implementation is easiest to manage from a Client perspective. My options for handling these errors seem to be as follows.

  1. Raise an exception and let the SOAP service generate a SoapFault. This would be fine except I have little (no) control over the structure of the message contained within the SOAP fault.
  2. Return an Http 400 response with an agreed data structure to indicate the error message. This structure would not be defined within the WSDL though.
  3. Include a Status element in all responses, whether successful or not and have that status element include a code and an array of error data (Including error messages).

Option three seems like the best solution but is also the most error prone to implement as the implementation of web services in ROR precludes me from implementing this in a generic way and each method becomes responsible for checking the result of the checks and rendering an appropriate response. Admittedly this would be a single function call and return on failure but it is relying on the developer to remember to do this as we add more options.

I appreciate that most ROR developers will say that this should be implemented as a REST service and I agree, in fact we already have REST services to do this but the spread of SOAP in the corporate world, and its impressive tooling support means that we have to provide SOAP services to remain competitive.

In your experience what would be the easiest implementation for clients to handle and does this differ dependant upon the libraries/language of the client process.

A: 

A SoapFault would be the preferred way to signify errors. SoapFaults can contain additional information in their <detail> element.

The advantage of a SoapFault over some status element is that the caller can use standard exception handling, instead of checking for some status field.

Sjoerd