【问题标题】:How to send REST call in WSO2ESB with "Date" transport header如何使用“日期”传输标头在 WSO2ESB 中发送 REST 调用
【发布时间】:2017-08-02 15:46:50
【问题描述】:

我正在尝试从 WSO2ESB 中调用 REST 服务。该请求需要包含一个身份验证代码,该代码将根据一些值进行计算,包括 Date 传输标头,该标头也必须是传输标头的一部分。

<syn:property name="Date" value="Mi, 1 Mrz 2015 11:00:00 MEZ" scope="transport" />
<syn:property name="X-Auth-Code" value="SomeCodeBasedOnDateHeader" scope="transport" />
<syn:send>
  <syn:endpoint>
    <syn:http uri-template="http://localhost:8280/rest/resourceA/{uri.var.resA}/resourceB/{uri.var.resB}" method="POST" />
  </syn:endpoint>
</syn:send>

但是在尝试发送请求时,WSO2 ESB 将删除 Date 传输标头(REST 服务不会获得任何 Date 标头)。是否有机会包含日期标题?

【问题讨论】:

    标签: rest wso2esb


    【解决方案1】:

    似乎在 NIO 和 Passthrough http 传输中都删除了这些标头:

    • 连接
    • 传输编码
    • 日期
    • 内容长度
    • 保持活动状态
    • 服务器
    • 用户代理

    您可以保留 ServerUser-Agent 标头,设置 http.server.preserve=truehttp.user。 ESB_HOME/repository/conf/nhttp.propertiespassthru-http.properties 中的 agent.preserve=true 取决于在axis2中配置的传输,但它看起来没有属性可以保留 Date 标头:您可能需要编写自己的 http 传输发送器并在 ESB_HOME/repository/conf/axis2/axis2.xml 中配置您的自定义类/em> : &lt;transportSender name="http" class="sss"&gt;

    【讨论】:

      【解决方案2】:

      您可以通过将以下属性添加到 D:\stack\wso2am-2.1.0\repository\conf\nhttp.properties D:\stack\wso2am-2.1.0\repository\conf\passthru-http.properties

      http.headers.preserve=Date
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-05-12
        • 1970-01-01
        • 1970-01-01
        • 2018-01-23
        • 2020-10-12
        • 1970-01-01
        • 2020-10-02
        相关资源
        最近更新 更多