【问题标题】:How to set REQUEST HEADER in spring Integration如何在 Spring Integration 中设置 REQUEST HEADER
【发布时间】:2014-11-11 22:37:30
【问题描述】:

我们有一个 asp 页面,它读取一些信息表单请求,如下所示:

varLogon = Request.ServerVariables("HTTP_logon")

如果我们想使用spring集成向asp页面发布东西,我们无法将HTTP_logon传递给页面,

这不行

任何想法,我们可以设置什么以及如何设置请求标头信息?

<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" /> 

【问题讨论】:

    标签: asp.net spring spring-integration


    【解决方案1】:

    您必须为&lt;int-http:outbound-gateway&gt; 指定header-mapper。默认情况下,它只映射标准 HTTP 标头:

    <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"/> 
    

    【讨论】:

      【解决方案2】:

      您可以使用以下路由组件根据标头值进行路由。

      <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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-06
        • 1970-01-01
        • 1970-01-01
        • 2022-01-15
        • 2017-12-12
        • 1970-01-01
        相关资源
        最近更新 更多