【发布时间】:2020-02-17 13:49:38
【问题描述】:
我想调用一个带有 JSON 负载的外部 REST 端点 POST 请求,该负载将通过 http 入站网关从另一个服务调用。
我正在为我的应用程序使用以下配置:
<int:channel id="xappSearchRequest" />
<int:channel id="xappSearchResponse" />
<int:channel id="xappFilterChannelOutput"/>
<int:channel id="discardFilterChannel"/>
<int:channel id="mutableMessageChannel"/>
<int:filter input-channel="mutableMessageChannel" output-channel="xappFilterChannelOutput" discard-channel="discardFilterChannel" ref="structureValidationFilter"/>
<int:transformer input-channel="xappSearchRequest" output-channel="mutableMessageChannel"
ref="mutableMessageTransformer" />
<int-http:inbound-gateway id="inboundxappSearchRequestGateway"
supported-methods="POST"
request-channel="xappSearchRequest"
reply-channel="xappSearchResponse"
mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"
path="${xapp.request.path}"
reply-timeout="50000"
request-payload-type="standalone.CFIRequestBody">
</int-http:inbound-gateway>
<int:service-activator id="xappServiceActivator"
input-channel="xappFilterChannelOutput"
output-channel="xappSearchResponse"
ref="xappSearchService"
method="handlexappRequest"
requires-reply="true"
send-timeout="60000"/>
<int:service-activator id="dicardPayloadServiceActivator"
input-channel="discardFilterChannel"
output-channel="xappSearchResponse"
ref="invalidPayloadService"
method="getInvalidMessage"
requires-reply="true"
send-timeout="60000"/>
<int-http:outbound-gateway id="get.outbound.gateway"
request-channel="get_send_channel" url="${cms.stub.request.url}"
http-method="POST" reply-channel="get_receive_channel"
expected-response-type="standalone.StubResponseBody">
</int-http:outbound-gateway>
无法弄清楚如何发送 JSON 负载和自定义标头来调用 POST 端点。
【问题讨论】: