空手道从请求中获取一个变量 [英] Karate get one variable from a request

查看:130
本文介绍了空手道从请求中获取一个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    Given request
"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.openkm.com">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:login>
         <!--Optional:-->
         <user>TestUser</user>
         <!--Optional:-->
         <password>TestUser</password>
      </ws:login>
   </soapenv:Body>
</soapenv:Envelope>
"""
When soap action 'http://ws.openkm.com/OKMAuth/login'
Then status 200
  * def token = //return

结果=响应= {soap:Envelope = { = {soap:Body = {ns2:loginResponse = { = ‌ 25c8},@ = {xmlns:ns2 = ws.openkm.com}}}},@ = {xmlns:soap = schemas.xmlsoap.org/soap/envelope}}},responseStatus = 200,__ loop = -1,responseCookies = null,令牌= a866fb4f-47e4-4895-ac13-2118b6c025c8}

Result = response={soap:Envelope={={soap:Body={ns2:loginResponse={=‌​ {return=a866fb4f-47e‌​4-4895-ac13-2118b6c0‌​25c8}, @={xmlns:ns2=ws.openkm.com}}}}, @={xmlns:soap=schemas.xmlsoap.org/soap/envelope}}}, responseStatus=200, __loop=-1, responseCookies=null, token=a866fb4f-47e4-4895-ac13-2118b6c025c8}

我从一个请求中得到了这个回应.我怎样才能从体内获得回报"或代币"?

I got this response from a request. How can I get the 'return' or the 'token' from the body?

推荐答案

您似乎尚未阅读

You don't seem to have read the documentation on calling features. Unless you are clear about how it works, I recommend you don't use call at all.

我(仍然)无法读取您的响应XML,所以我不能说//return是否确实为您提供了您想要的值.假设确实如此,您现在已将其分配给了右侧RequestToken.feature中名为result的变量.因此,现在尝试一下:

I am (still) not able to read your response XML, so I can't say if //return actually gets you the value you want. Assuming that it does, you have now assigned it to a variable called result in RequestToken.feature right. So now, try this:

# this result will again contain a variable 'result'
* def result = call creator
* def return = result.result
* print return

除非您认真阅读文档,否则我无济于事.

I can't help more unless you read the doc carefully, all the best.

这篇关于空手道从请求中获取一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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