cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a mock response that returns a 429 status code (not in the list of choices)?

Highlighted
Contributor

How to create a mock response that returns a 429 status code (not in the list of choices)?

I'm trying to use soapui to create a mock REST server that responds with a 429 status code.  I was going through the steps when I got to the mock response, and I saw I could select the response status code from the dropdown.  Unfortunately, 429 is not one of the options.  How can I create a mock response that returns a 429 status code?

1 REPLY 1
Contributor

Re: How to create a mock response that returns a 429 status code (not in the list of choices)?

I heard that I can do this by changing the dispatch type to "Script" instead of "Sequence", but it's not at all obvious what to write in the script.

 
Note that I'm now running v5.5.0 (opensource).

 

I tried changing the mock action from "Sequence" to "Script". I then tried a very simple script, like the following:

mockRequest.httpResponse.status = 429

I then click the Play button, which when I was using "Sequence", this would just start the listener and wait for requests to come in. Instead, when I clicked the Play button, it immediately failed with:

com.eviware.soapui.impl.wsdl.mock.DispatchException: Failed to dispatch
using script; java.lang.NullPointerException: Cannot get property 
'httpResponse' on null object

I then added a line like the following before this line:

log.info("mockRequest[" + mockRequest + "]")

When I clicked Play again, it printed this in the script log:

Sat Jan 18 08:53:24 PST 2020:INFO:mockRequest[null]

I am obviously missing some basic details in the setup of this.