0

I am calling hybris rest services from mule using HTTP outbound component. When i call service 1st time i got JSESSIONID in Set-Cookie but in 2nd call JSESSIONID is not present in Set-Cookie.

Same scenario i have tried using Rest Client. I directly call hybris services from rest client.Rest Client Each time give me JSESSIONID in Set-Cookie.

Why JSESSIONID not getting second call of HTTP outbound component?

Here is my flow

<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>
2
  • 1
    you are probably getting confused with inbound and outbound headers, please add your xml configuration to get enough information to help you. Nov 20, 2014 at 14:51
  • hey i have update my question..added xml..
    – Kalpesh
    Nov 20, 2014 at 17:23

1 Answer 1

1

I'm unsure why it does work the first time because it shouldn't. I assume you are checking using the "Oauth request" logger. If that is the case, please use a different client, it is working fine forme.

However, JSESSIONID won't be sent to the secondary system unless you copy the property from the inbound scope to the outbound with the following:

<copy-properties propertyName="JSESSIONID" />

I would recommend object-to-string rather than the echo-component. Also if you are writing a client for hybris I would rather recommend creating a connector using DevKit, that would provide you a oauth authentication mechanism for free plus a much more reusable module.

5
  • This code working fine..i got oauth token each time..but i didnt get JSESSIONID in http headers on second call..
    – Kalpesh
    Nov 20, 2014 at 18:21
  • What do you mean with 'get', is that at hybris? at the inbound endpoint? Nov 20, 2014 at 18:22
  • at hybris..When i call 1st time i am getting this response in Set-tCookie of http header - [_hybris.tenantID_=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/JSESSIONID=57B9D344AD0CBD39D3A433B28F7DF08A; Path=/rest]...then next every call i am getting [_hybris.tenantID_=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/] in this JSESSIONID is missing.
    – Kalpesh
    Nov 20, 2014 at 18:39
  • oh! I that is quite a different thing. This is not a problem of Mule indeed, you'll need to refer to hybris logs to find out why with two identical requests you get two different responses (this could be potentially correct). Nov 20, 2014 at 19:16
  • Same scenario i have tried using Rest Client. I directly call hybris services from rest client.Rest Client Each time give me JSESSIONID in Set-Cookie.
    – Kalpesh
    Nov 21, 2014 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.