在SOAP UI模拟响应脚本中访问请求XML [英] Access the request XML in a SOAP UI mock response script

查看:90
本文介绍了在SOAP UI模拟响应脚本中访问请求XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模拟响应,它需要返回请求中的值。例如,此请求可以进入:

 < myReqest>< myValue> 123< / myValue>< / myRequest> ; 

我已经有了一个mockResponse:

 < myResponse>< yourValue> $ {theValue}< / yourValue>< / myResponse> 

我知道如何通过上下文变量设置$ {theValue}的值, t找出如何访问请求并解析它的值。



任何帮助都将非常感谢。



感谢,
Jonny

解决方案

您可以使用脚本功能来自定义您的响应。 b
$ b

在mockResponse窗口中,您可以单击脚本菜单。



在这里,您可以将类似限定你正在寻找的元素):
$ b $ pre $ context.theValue =
mockRequest.getRequestXmlObject()。selectPath( //消息/文本())[0];

当您调用 MockResponse 时,<$应自动更新c $ c> 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

解决方案

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):

context.theValue = 
mockRequest.getRequestXmlObject().selectPath("//Message/text()")[0];

When you invoke the MockResponse, theValue variable should be automatically updated.

这篇关于在SOAP UI模拟响应脚本中访问请求XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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