WSO2 ESB - 如何在 WSDL 调用中获取和设置 cookie [英] WSO2 ESB - How to get and set cookies in WSDL calls in

查看:29
本文介绍了WSO2 ESB - 如何在 WSDL 调用中获取和设置 cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 WSO2 ESB 并希望将 2 个 Web 服务连接在一起 - 在计时器上从一个服务中提取数据并将其推送到另一个服务.

I use WSO2 ESB and want to connect 2 web services together - on a timer pull data from one service and push it to another.

问题是其中一项服务使用 cookie 对调用者进行身份验证.您首先需要使用用户名和密码调用 GetSession 方法.对此调用的响应设置了一个 cookie.然后用这个 cookie 进行其他调用.

The problem is that one of the services authenticates callers with cookies. You first need to call a GetSession method with the username and password. The response to this call sets a cookie. Then with this cookie you make other calls.

我在文档中找不到任何地方,如何从一次调用的结果中获取 cookie 并将其设置为后续调用.它完全可以实现吗?如果是这样 - 如何?

I couldn't find anywhere in the documentation, how can I get a cookie from the result of one call and set it for a subsequent call. Is it at all achievable? If so - how?

这是我的序列码:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="SampleName" trace="enable">
   <payloadFactory media-type="xml">
      <format>
         <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
            <Body>
               <GetSessionWithCredentials xmlns="blabla">
                  <User>bla</User>
                  <Password>bla</Password>
               </GetSessionWithCredentials>
            </Body>
         </Envelope>
      </format>
   </payloadFactory>
   <call>
      <endpoint key="conf:/Tracker"></endpoint>
   </call>
   <payloadFactory media-type="xml">
      <format>
         <GetTrackingList xmlns="blabla"></GetTrackingList>
      </format>
   </payloadFactory>
   <property xmlns:ns="http://org.apache.synapse/xsd" name="Cookie" expression="$trp:Cookie"></property>
   <call>
      <endpoint key="conf:/Tracker"></endpoint>
   </call>
   <log level="full"></log>
</sequence>

非常感谢

推荐答案

get Cookie header : <property name="Cookie" expression="$trp:Cookie"/>如果你想得到一个 cookie 并且它的值,例如使用带有 'substring' 的 xpath 表达式

get Cookie header : <property name="Cookie" expression="$trp:Cookie"/> If you want to get one cookie and it's value, use xpath expression with 'substring' for exemple

使用值 JSESSIONID=1 设置 cookie 标头:<property name="Cookie" value="JSESSIONID=1" scope="transport"/>

set cookie header with value JSESSIONID=1 : <property name="Cookie" value="JSESSIONID=1" scope="transport"/>

这篇关于WSO2 ESB - 如何在 WSDL 调用中获取和设置 cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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