我有以下http出站网关。如何使用Java Config或Spring DSL进行此配置?
<int-http:outbound-gateway id="test"
url="http://localhost:8080/"
http-method="POST"
charset="UTF-8"
header-mapper="soapHeaderMapper"
request-factory="requestFactory"
request-channel="inputChannel"/>
最佳答案
@Bean
public IntegrationFlow httpOut() {
return IntegrationFlows.from("inputChannel")
.handle(Http.outboundGateway("http://localhost:8080/")
.charset("UTF-8")
.httpMethod(HttpMethod.POST)
.headerMapper(soapHeaderMapper())
.requestFactory(requestFactory()), e -> e.id("test"))
.get();
}
或者
@ServiceActivator(inputChannel="inputChannel")
@Bean(name="test")
public MessageHandler httpout() {
HttpRequestExecutingMessageHandler handler = new ...
...
return handler;
}