views:

211

answers:

3

Hello,

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

A: 

Hi jonny

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

Sprotty
+1  A: 

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.

khylo
+1 for xpath. Here is where the Pro version really shines, it's got an XPath tool built in, making this sort of thing very easy.
Chris Thornton
A: 

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

straurob