Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Integration Get HTTP Outbound Gateway Response

I need to POST a REST service call and get the data it returns (all of this is with JSON). I have an outbound-gateway with its reply-channel as a chain, and the chain has one transformer.

<int-http:outbound-gateway
    url="#{appProperties['rootUrl']}#{appProperties['myMethod']}"
    request-channel="myRequestChannel" reply-channel="myResponseChannel" >
</int-http:outbound-gateway>

<int:channel id="myResponseChannel"/>

<int:chain input-channel="myResponseChannel">
    <int:transformer ref="genericResponseTransformer"/>
</int:chain>

However when I debug through the transformer, the payload I get back is just an HttpStatus object.

Maybe I'm doing something wrong? Any help would be greatly appreciated. Thanks!

like image 250
Alex Beardsley Avatar asked Jan 18 '23 11:01

Alex Beardsley


1 Answers

If you do not specify expected-response-type in your gateway, the default behavior is that the response message contains only status code (expected-response-type is null). Try setting expected-response-type="java.lang.String":

<int-http:outbound-gateway
  url="#{appProperties['rootUrl']}"
  http-method="#{appProperties['myMethod']}"
  expected-response-type="java.lang.String"
  request-channel="myRequestChannel" reply-channel="myResponseChannel" />
like image 119
omnomnom Avatar answered Mar 16 '23 04:03

omnomnom