1

We have a legacy application that allows our developers to "add" messages via a ThreadLocal in Java.

The current SOAP endpoints will scoop these messages off the thread and then package them up in the response.

The endpoints also catch all exceptions and then marshal those exceptions via this same mechanism to normalize the passing of messages (be they informational, warning, or error).

These messages are rich objects (they have a code, severity, classification, and then the actual message text.)

This is nice in many ways because now we have a standard way to communicate meaningful messages to the user (or calling service) but it also makes using the API more challenging because now the client must pick out the messages from the response AND also pick out the real payload.

Any web service can communicate messages this way...but only a handful do.

I would like to start moving our application towards a REST API but I am struggling on how best to handle the messaging. I am not super keen on adding an envelope to each of our REST responses because this really pollutes the API.

The alternative appears to be adding these messages to custom HTTP headers. Is this the "preferred" approach? Remember I will have a list of one or more of these messages and I will likely have to serialize them as json as well.

Thanks.

Tyler Van Gorder
  • 453
  • 6
  • 14

0 Answers0