I am using Spring Integration as an abstraction to a target REST service that returns JSON in all cases--a "document" object when things go well and an "error" object when things go awry. The tricky thing implied here is that the response is always HTTP 200; the only difference is the JSON returned.
Here is the configuration of the outbound call:
Since the JSON could either be a document or an error, I believe I need to get rid of expected-response-type. The problem is that when I do that, SI considers the payload to be just the status rather than the JSON that comes back. As a result, the following doesn't work for me:
...because SI just sees the payload as an HttpStatus object.
<mapping type="com.myapp.Document" channel="documentResponseChannel"/>
<mapping type="com.myapp.ErrorResponse" channel="errorResponseChannel"/>
Is it possible to do what I am trying to do? If so, how?