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.