在第二个HTTP请求中,MULE不在头中提供JSESSIONID

时间:2014-11-20 12:30:00

标签: cookies http-headers mule mule-studio

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

相同的情况我尝试过使用Rest Client。我直接从rest client调用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>

1 个答案:

答案 0 :(得分:1)

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

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

<copy-properties propertyName="JSESSIONID" />

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