在 WSO2 ESB 中,如何存储 cookie 并在以后使用它们进行身份验证? [英] In WSO2 ESB, how to store cookies and use them later for authentication?

查看:24
本文介绍了在 WSO2 ESB 中,如何存储 cookie 并在以后使用它们进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在调用的服务,它返回带有身份验证信息的 cookie.我如何存储 cookie 并在以后使用它们?

I have a service that I am calling, which is returning back cookies with authentication info. How do I store the cookies, and use them later?

这对我不起作用.我看到 cookie 被退回,但我没有看到它被设置.

This is not working for me. I see the cookies being returned back, but I don't see it getting set.

<!-- LOGON CALL -->
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="setCookieHeader" expression="$trp:cookie"></property>
<payloadFactory media-type="xml">
    <format><somexml></somexml></format>
</payloadFactory>
<call>
    <endpoint>
       <address uri="http://serviceurl.domain.com" format="pox"></address>
    </endpoint>
</call>
<log>
<property name="cookie" expression="get-property('setCookieHeader')"></property>
</log>
<!-- The Above Log statement prints correctly -->

<!-- Second Service CALL -->
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="setCookieHeader" expression="$trp:cookie"></property>
<payloadFactory media-type="xml">
    <format><somexml></somexml></format>
</payloadFactory>
<call>
    <endpoint>
       <address uri="http://serviceurl.domain.com" format="pox"></address>
    </endpoint>
</call>

推荐答案

从响应中获取 cookie :

To get cookies from the response :

<property name="setCookieHeader" expression="$trp:Set-Cookie" scope="default" type="STRING"/>

为下一个请求设置cookies:

To set cookies for the next request :

<property name="Cookie" expression="$ctx:setCookieHeader" scope="transport"/> <!-- if setCookieHeader has been initialized before -->

<property name="Cookie" expression="$trp:Set-Cookie" scope="transport"/>

这篇关于在 WSO2 ESB 中,如何存储 cookie 并在以后使用它们进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆