英文:
Assign child node from a JSON response to project variable everytime a request is sent in SoapUI
问题
是的,您可以从JSON响应中提取数据并将其分配给项目变量,然后可以在另一个请求中进一步使用它。在您的情况下,您希望提取身份验证令牌。希望这可以帮助您。
英文:
I am new to soapUI and still figuring it out.
Is it possible to extract data from a JSON response and assign it to a project variable which can further be used in another request. In my case it's an authentication token.
Appreciate all your responses.
Found nothing specific on internet regarding this.
答案1
得分: 0
使用属性传递完成了。
添加一个属性传递步骤,选择前一个REST请求的响应,并使用Xquery获取子节点,然后将其分配给项目变量。
例如:
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Save", "onclick": "SaveDoc()"}
]
}
}}
使用Xquery,"$.menu.popup.menuitem.value",来访问相应的子节点。
英文:
I did it using property transfer.
Add a property transfer step, and select the response of the previous REST request, and use Xquery to get the child node, and assign it to the project variable.
For eg:
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Save", "onclick": "SaveDoc()"}
]
}
}}
Use the Xquery, "$.menu.popup.menuitem.value", to access the respective child node.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论