如何在没有xml配置的情况下创建int-http:outbound-gateway

时间:2019-05-08 07:02:28

标签: spring http spring-integration outbound

如何将下面的Spring Integration XML配置转换为Java配置bean。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:int-http="http://www.springframework.org/schema/integration/http"
       xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/integration
    http://www.springframework.org/schema/integration/spring-integration.xsd
    http://www.springframework.org/schema/integration/http
    http://www.springframework.org/schema/integration/http/spring-integration-http.xsd">

    <int:channel id='reply.channel'>
        <int:queue capacity='10' />
    </int:channel>
    <int:channel id='get.request.channel'/>

    <int-http:outbound-gateway id="outbound.gateway"
                               request-channel="get.request.channel" url="{fhirurl}"
                               http-method-expression="payload.getHttpMethod()" expected-response-type-expression="payload.getResponseType()"
                               charset="UTF-8" reply-timeout="5000" reply-channel="reply.channel">

        <int-http:uri-variable name="fhirurl" expression="payload.getUrl()"/>

    </int-http:outbound-gateway>

</beans>

我得到了以下代码,但无法使用 您能帮我在soapHeaderMapper和requestFactory中写些什么吗?

@Bean
    public IntegrationFlow httpOut() {
        return IntegrationFlows.from("reply.channel")
                .handle(Http.outboundGateway("http://localhost:8080/")
                        .charset("UTF-8")
                        .httpMethod(HttpMethod.GET)
                        .headerMapper(soapHeaderMapper())
                        .requestFactory(requestFactory()), e -> e.id("test"))
                .get();
    }

高级谢谢

0 个答案:

没有答案