How to set REQUEST HEADER in spring Integration

2019-07-03 16:55发布

We have a asp page which reading some information form request like this:

varLogon = Request.ServerVariables("HTTP_logon")

If we want to post something to the asp page using spring integration, we are unable to pass the HTTP_logon to the page,

This is not working

Any idea, what and how we can set the request header information?

<int:header-enricher input-channel="pdfgenheaderchannel" output-channel="pdfgenchannel">
    <int:header name="HTTP_ordernumber" method="getOrdernumber" ref="reportbean"/>
    <int:header name="reportID" method="getReportID" ref="reportbean"/>
    <int:header name="Content-Type" value="text/html"/>
    <int:header name="logon" value="orderADCB"/>
    <int:header name="HTTP_logon" value="orderADCB"/>
</int:header-enricher>

<int-http:outbound-gateway id="pdfgenerationoutboundgateway"
                           request-channel="pdfgenchannel"
                           url="http://x.xy.xx.y/convertHTMLtoPDF.asp"
                           http-method="POST"
                           expected-response-type="java.lang.String"
                           charset="UTF-8"
                           reply-channel="replyChannel"
                           request-factory="requestFactory" /> 

2条回答
疯言疯语
2楼-- · 2019-07-03 17:25

You have to specify a header-mapper for the <int-http:outbound-gateway>. By default it maps only standard HTTP headers:

<beans:bean id="headerMapper" class="org.springframework.integration.http.support.DefaultHttpHeaderMapper"
                factory-method="outboundMapper">
    <beans:property name="outboundHeaderNames" value="*"/>
    <beans:property name="userDefinedHeaderPrefix" value=""/>
</beans:bean>

<int-http:outbound-gateway header-mapper="headerMapper"/> 
查看更多
劳资没心,怎么记你
3楼-- · 2019-07-03 17:36

You can user following routing component to route according to header values.

<int:header-value-router input-channel="routingChannel" header-name="headerObject">
        <int:mapping value="value1" channel="channel1" />
        <int:mapping value="calue2" channel="channel2" />
    </int:header-value-router>
查看更多
登录 后发表回答