空手道 - 如何使用从响应数组接收到的值循环 Soap 请求
Karate - How to loop Soap request with values received from a response array
我正在发出 Soap 请求,我正在接收以数组形式返回的响应:
- [print] [
"M4205N",
"M4206U"
]
对于数组中的每一项,我想发出另一个 Soap 请求。我已经阅读了如何使用 tables and call a feature file, and I've read how to loop through an array 执行此操作并调用 js 函数。我不知道如何遍历数组,并将每个值传递给另一个 soap 请求 xml(一次一个)。
我想做这样的事情:
- 给定 soapURL
- 和方法post
- def responseArray = /xml 我想要的代码的路径/
- def result = call read('otherRequest.feature') responseArray
otherRequest.feature 文件看起来像这样:
@ignore
Feature:
Background:
* def myNewRequest = read('soap.xml')
Scenario:
Given soapURL
* replace myNewRequest
| token | value |
| @@refNum@@ | responseArrayValue |
When request myNewRequest
And method post
但是,我得到这个错误:
GetNewMessageList.feature:27 - argument not json or map for feature call loop array position: 0, M4205N
如何遍历数组中的每一项,并将每个值传递给另一个特征文件?
添加这一行应该可以满足您的需求。是的,硬性要求 "loop" 数组应该是 JSON 对象的数组。但是您可以一步转换一组基元:
* def responseArray = karate.mapWithKey(responseArray, 'responseArrayValue')
我正在发出 Soap 请求,我正在接收以数组形式返回的响应:
- [print] [
"M4205N",
"M4206U"
]
对于数组中的每一项,我想发出另一个 Soap 请求。我已经阅读了如何使用 tables and call a feature file, and I've read how to loop through an array 执行此操作并调用 js 函数。我不知道如何遍历数组,并将每个值传递给另一个 soap 请求 xml(一次一个)。
我想做这样的事情:
- 给定 soapURL
- 和方法post
- def responseArray = /xml 我想要的代码的路径/
- def result = call read('otherRequest.feature') responseArray
otherRequest.feature 文件看起来像这样:
@ignore
Feature:
Background:
* def myNewRequest = read('soap.xml')
Scenario:
Given soapURL
* replace myNewRequest
| token | value |
| @@refNum@@ | responseArrayValue |
When request myNewRequest
And method post
但是,我得到这个错误:
GetNewMessageList.feature:27 - argument not json or map for feature call loop array position: 0, M4205N
如何遍历数组中的每一项,并将每个值传递给另一个特征文件?
添加这一行应该可以满足您的需求。是的,硬性要求 "loop" 数组应该是 JSON 对象的数组。但是您可以一步转换一组基元:
* def responseArray = karate.mapWithKey(responseArray, 'responseArrayValue')