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
Select File > Import Project. Specify a path to the project XML file, or click Browse and navigate to the file manually. Click OK.
To view the HTTP request, click RAW at SoapUI Request window (left side). The Request is posted to the web-server. Hence, the POST method of Http is used. The SOAP Request is transported in the body of the http message, which is shown as follows.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With