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

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

问题描述

我使用WSO2 ESB并想要连接2个Web服务在一个定时器拉数据从一个服务,并推到另一个。



问题是其中一项服务使用Cookie验证来电者。您首先需要使用用户名和密码调用GetSession方法。对此调用的响应设置cookie。



我在文档中找不到任何地方,如何从一个调用的结果中获取一个cookie,并将其设置为后续呼叫。是否可以实现?


$ b 这是我的序列号:

  < sequence xmlns =http://ws.apache.org/ns/synapsename =SampleNametrace =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/xsdname =Cookieexpression =$ trp:Cookie>< / property>
< call>
< endpoint key =conf:/ Tracker>< / endpoint>
< / call>
< log level =full>< / log>
< / sequence>

非常感谢

解决方案

获取Cookie标头:< property name =Cookieexpression =$ trp:Cookie/>
要获取一个cookie及其值,请将xpath表达式与'substring'结合使用,例如



设置值为JSESSIONID = 1的Cookie标头:< property name =Cookievalue =JSESSIONID = 1scope =transport/>


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.

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.

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?

Here is my sequence code:

<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>

Thanks a lot

解决方案

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

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

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

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