在 SOAP UI 模拟响应脚本中访问请求 XML
我有一个模拟响应,它需要返回请求中的值。例如,这个请求可以进来:
<myReqest><myValue>123</myValue></myRequest>
我已经有一个mockResponse:
<myResponse><yourValue>${theValue}</yourValue></myResponse>
我知道如何通过上下文变量设置${theValue}的值,但我不知道如何访问该请求并解析它的值。
任何帮助将不胜感激。
谢谢, 强尼
I have a mock response, which needs to return a value that was in the request. For example, this request can come in:
<myReqest><myValue>123</myValue></myRequest>
I already have a mockResponse:
<myResponse><yourValue>${theValue}</yourValue></myResponse>
I know how to set the value of ${theValue} through the context variable, but I can't figure out how to access the request and parse it for the value.
Any help would be much appreciated.
Thanks,
Jonny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用脚本功能来自定义您的响应。
在mockResponse窗口中,您可以单击脚本菜单。
在这里您可以输入类似的内容(使用 XPath 完全限定您要查找的元素):
当您调用
MockResponse
时,theValue
变量应该自动更新。You can use the scripting feature to customize your response.
In the mockResponse window, you can click on the script menu.
In here you can put something like (using XPath to fully qualify the element you are looking for):
When you invoke the
MockResponse
,theValue
variable should be automatically updated.SoapUI 在模拟服务脚本中获取请求参数的问题/答案 几乎是一样的。
总结一下:
The question/answer of SoapUI getting request parameters in mock service script is almost the same.
To summarize:
使用 Dispatch SEQUENCE,MokcResponse 可以是:
Using Dispatch SEQUENCE the MokcResponse can be:
我不完全确定上下文,您使用哪种工具?
我们使用 Liquid XML Studio,它有一个 Web 服务测试客户端,这使得手动调用 Web 服务变得非常简单,这听起来像是您想要做的事情,但也许您正在尝试自动化此过程以进行测试?
请提供更多信息。
西蒙
I'm not entirely sure of the context, which tool are you using?
We use Liquid XML Studio, which has a Web Services Test Client, which makes manually calling web services pretty straightforward, this kind of sounds like what your trying to do, but maybe you are trying to automate this process for testing?
Please provide a bit more info.
Simon
如果您使用的是 SoapUI Pro,只需将光标放在要插入值的位置,然后右键单击并通过“获取数据...”子菜单从请求中选择参数。不过,此功能仅在专业版中可用。使用免费软件版本,您应该遵循 khylo 的答案。
罗伯特
If you're using SoapUI Pro just place the cursor where you want the value to be inserted, then right-click and select the parameter from the request via the "Get data..." submenu. This feature however is only available in the Pro version. Using the freeware edition you should follow khylo's answer.
Robert