RESTful API Mocking

REST Service Mocking

The REST Service Mocking feature lets you create a simulation of a REST services, a MockService.

The REST mocks can then be run either from inside SoapUI or from the command line with the runner mockservicerunner.bat/sh.


REST MockServices can for example be used for:

  • Web Services Prototyping - generate a complete static mock implementation from a request in seconds. This allows you to implement and test clients much faster than if you had needed to wait for the actual solution to get build.
  • Client Testing/Development - create mock implementations of desired operations and set up a number of alternative responses (including scripts, attachments and custom http headers). Clients can be developed against the MockService and tested without access to the live services. Responses can be cycled, randomized or selected with XPath expression from incoming request
  • Test Driven Development - Create Functional and Load Tests in soapUI against a MockService before or during the actual services being implemented

MockServices comply with standards and client can use them just as if they are real services.


MockServices can be further expanded and made even more dynamic through scripting. By adding scripts almost any desired behavior can be simulated, including - but not limited to - dynamic results, random errors, fixed responses with variables, and so on.

The MockService model

MockServices provide simulate a service by exposing an arbitrary number of MockActions which each in turn can contain any number of configured MockResponse messages:

  • MockService
    • MockAction
      • MockResponses

A MockService in SoapUI may look like this:

A Sample Mock Service

In this example, the MockService contains two actions, one GET and one POST. If we open the POST action, we can see the responses it contains:

A Sample Mock Action

The action shows the Method and Resource Path, and a list of all the MockResponses. The Dispatch setting - "SEQUENCE" in this case - indicates that the when the mockservice recieves a request, the responses will be used once each, in the order listed and then start over from the beginning.

Looking at the "Successful" response:

A Sample Mock Response

The MockResponse contains the configurable information that will be returned for the request: A HTTP Status Code, any custom Header information to include, and the Response Body. Tabs for scripting and related settings are at the bottom.