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:

Code:
<http:outbound-gateway                 
                           id ="documentByIdAdapter"
                           url="http://localhost:8080/myapp/documents/{id}"
                           http-method="GET"
                           request-channel="documentByIdRequestChannel"
                           reply-channel="myappDocumentByIdReplyChannel"
                           expected-response-type="com.myapp.Document"
                           charset="UTF-8"/>
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:

Code:
<payload-type-router input-channel="routingChannel">
        <mapping type="com.myapp.Document" channel="documentResponseChannel"/>
        <mapping type="com.myapp.ErrorResponse" channel="errorResponseChannel"/>
    </payload-type-router>
...because SI just sees the payload as an HttpStatus object.

Is it possible to do what I am trying to do? If so, how?

Thanks.