Viren Pushpanayagam
Viren Pushpanayagam

Reputation: 2497

SoapUI Mock service groovey script to select right response

I have a mock service that has an operation with two possible responses. How can I select the right response based on a condition using scripting? Eg.

if(context.sessionID == ''){
 // use response 1 
} else {
 // use response 2
}

Upvotes: 1

Views: 5460

Answers (2)

gaelperret
gaelperret

Reputation: 328

If your code is in the dispatch script of the "MockResponses" then the correct syntax is:

return "response 1"

[EDIT] This is well-explained in the official web-site: http://www.soapui.org/Service-Mocking/creating-dynamic-mockservices.html#5-selecting-a-response-based-on-the-request

Upvotes: 3

Viren Pushpanayagam
Viren Pushpanayagam

Reputation: 2497

context.httpResponse = "response 1"

Upvotes: -1

Related Questions