Spring Integration Get HTTP Outbound Gateway Response

I need to make a POST call to the REST service and get the returned data (all with JSON). I have an outgoing gateway with my response 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 a transformer, the payload that I receive is just an object of HttpStatus.

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

+4
source share
1 answer

If you do not specify expected-response-type in your gateway, the default behavior is that the response message contains only a 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" /> 
+9
source

Source: https://habr.com/ru/post/1396688/


All Articles