【问题标题】:karate : handling soap response from a called feature filekarate : 处理来自被调用功能文件的肥皂响应
【发布时间】:2020-07-12 01:36:19
【问题描述】:

first.feature 给定你的''

  • def 有效负载 = 读取('')
  • 请求负载
  • 肥皂动作''
  • 值 = /信封/正文/响应/结果/数量
  • print value # 按预期正确打印值

second.feature 背景: *def fetch = read('first.feature') *def data = 调用 fetch

场景:

  • print data.response #以json格式打印soap响应。
  • def res = data.response
  • 打印 res["s:Envelope"][""]["s:Body"]["Response"][""]["Result"]["_"][ "a:num']

first.feature 按预期工作(响应在肥皂中) 当我尝试在另一个功能中调用此功能时,响应为 json 格式。

我想使用此响应中的值将其传递给另一个请求。 我不得不使用 res["s:Envelope"]["_"]["s:Body"][][].. 来达到这个目的。

有没有办法像我们在 first.feature 中那样轻松地从这个响应中获取一个值? 请任何人告诉我如何实现这一目标。

【问题讨论】:

    标签: karate


    【解决方案1】:

    进行此更改:

    * xml res = data.response
    

    我们将在下一个版本中对此进行改进,如果您可以测试develop分支并确认:https://github.com/intuit/karate/wiki/Developer-Guide

    【讨论】:

    • 感谢彼得的快速回复。
    • from * xml res 我可以通过 $res /Envelope/Body/..... 从soap响应中获取值
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-27
    • 1970-01-01
    相关资源
    最近更新 更多