【问题标题】:MULE not give JSESSIONID in header on 2nd HTTP requestMULE 在第二个 HTTP 请求的标头中没有给出 JSESSIONID
【发布时间】:2016-05-19 19:17:31
【问题描述】:

我正在使用 HTTP 出站组件从 mule 调用 hybris rest 服务。 当我第一次调用服务时,我在 Set-Cookie 中获得了 JSESSIONID,但在第二次调用中,Set-Cookie 中不存在 JSESSIONID。

我尝试过使用 Rest Client 的相同场景。我直接从 rest 客户端调用 hybris 服务。Rest Client 每次在 Set-Cookie 中给我 JSESSIONID。

为什么 JSESSIONID 没有得到 HTTP 出站组件的第二次调用?

这是我的流程

<flow name="Oauth" doc:name="Oauth">
        <http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8081" doc:name="Oauth"
            path="getOauth" />
        <logger
            message="Oauth Request : #[message.payload]"
            level="INFO" doc:name="LogOuthRequest" />

        <http:outbound-endpoint exchange-pattern="request-response"
            host="hybrisServer" port="port" path="rest/oauth/token"
            method="POST" contentType="application/x-www-form-urlencoded"
            doc:name="HybrisPostRestCall">
            <message-properties-transformer name="test"
                doc:name="Set Content-type xml">
                <add-message-property key="accept"
                    value="application/xml" />
            </message-properties-transformer>
        </http:outbound-endpoint>
        <echo-component doc:name="Object2String" />
        <logger message="AccessToken : #[message.payload]"
            level="INFO" doc:name="LogOauthResponse" />
</flow>

【问题讨论】:

  • 您可能对入站和出站标头感到困惑,请添加您的 xml 配置以获得足够的信息来帮助您。
  • 嘿,我已经更新了我的问题..添加了 xml..

标签: cookies http-headers mule mule-studio


【解决方案1】:

我不确定为什么它第一次会起作用,因为它不应该。我假设您正在使用“Oauth request”记录器进行检查。如果是这种情况,请使用其他客户端,它可以正常工作。

但是,JSESSIONID 不会发送到辅助系统,除非您使用以下内容将属性从入站范围复制到出站:

<copy-properties propertyName="JSESSIONID" />

我会推荐 object-to-string 而不是 echo-component。此外,如果您正在为 hybris 编写客户端,我宁愿建议使用 DevKit 创建连接器,这将为您提供免费的 oauth 身份验证机制以及更可重用的模块。

【讨论】:

  • 这段代码工作正常..我每次都得到 oauth 令牌..但我在第二次调用时没有在 http 标头中获得 JSESSIONID..
  • 你的'get'是什么意思,是在hybris吗?在入站端点?
  • 在 hybris ..当我第一次打电话时,我在 http 标头的 Set-tCookie 中收到此响应 - [_hybris.tenantID_="";到期时间=周四,1970 年 1 月 1 日 00:00:10 GMT;路径=/JSESSIONID=57B9D344AD0CBD39D3A433B28F7DF08A; Path=/rest]...然后接下来我收到的每个电话 [_hybris.tenantID_="";到期时间=周四,1970 年 1 月 1 日 00:00:10 GMT;此 JSESSIONID 中的 Path=/] 缺失。
  • 哦!我那是完全不同的事情。这确实不是 Mule 的问题,您需要参考 hybris 日志来了解为什么使用两个相同的请求会得到两个不同的响应(这可能是正确的)。
  • 我尝试过使用 Rest Client 的相同场景。我直接从 rest 客户端调用 hybris 服务。Rest Client 每次在 Set-Cookie 中给我 JSESSIONID。
猜你喜欢
  • 2017-01-13
  • 1970-01-01
  • 1970-01-01
  • 2016-05-23
  • 1970-01-01
  • 2017-07-21
  • 2013-05-11
  • 2015-05-18
  • 1970-01-01
相关资源
最近更新 更多