Forum Discussion
Hi,
If I am understanding you correctly you have a situation like this:
Mock
-operation 1 (recieve details from request e.g. firstname & suranme)
-operation 2 (use those same details to populate the response)
Is this right?
If so, I would normally use Groovy scripts in the mock and a lightweight means of persisting the request data from operation 1 and retrievining it and using it to populate the response in operation 1. For this I have often used an in-memory H2 DB to persist the data. This approach is actually quite easy and doesn't take much code!
If you don't like the sounds of the lightweight DB, another mock Groovy script implementation might use a HashMap stored in the mock's context variable to persist the data. Actual quite similar in terms of code.
By the way, both of these approaches are covered in my SoapUI cookbook (sorry for blatant the self publicity! :-)) - but I would be more than happy to try to provide you with code snippets etc if you would like more help with either of the above approaches?
Hope this helps,
Rupert
Sorry, I also forgot to mention an even simpler way to persist the request data is just to store the data as individual properties in the mock's context variable and just use those to populate the second operations response. Whilst this is simpler, care needs to be taken if you want to test this with multiple requests, as the porpeties in the context would be shared and potentially overitten by simultaneous requests! If you just want to call the first operation, then the second in a single TestCase then it should be fine.
Again can provide Groovy code snippets if you need more help getting started.
Cheers,
Rupert