top of page

Mock Services in Soap UI

The SOAP service mocking feature allows you to simulate a SOAP service by creating a mock service.

Uses of Mock services in Soap UI:

  • Create a web service prototype. You can generate a complete mock service using just a single request. In this case, you can implement and test clients much faster, since there is no need to create a complex working solution.

  • Develop and test client applications. You can simulate requests you want to test and prepare a number of various responses for them. These responses can contain scripts, custom HTTP headers, attachments, and other content. You can cycle or randomize the responses, or prepare specific responses for certain requests.

  • Test every aspect of your future service. With SoapUI, you can perform functional and load testing against a mock service before even creating an actual live service.

Let's create Mock services.

Step 1:

Right click on the SOAP Interface and select Generate SOAP Mock Service

dialog box appears, select the interfaces need to have mock responses and click OK.

Set a name for your mock service,

You can see the MockService created for the selected interface.

Step 2:

Click on the Response XML, you see the response tab with mock response.

Edit the response with the value you want.

Step 3:

To invoke mock services, double click on created mock service interface and click on green play button, you will see the test starts running on port specified while creating mock, and the red stop button enabled.

Step 4: Let us create a request that will be sent to the mock service. To do that, click Create SOAP Request in the operation editor.

The Open Request dialog will appear. Use it to open one of the existing requests in the project – that is, select a request from the drop-down list, then click OK.

After the request editor shows up, you can submit the request by clicking green play button. Now you can see the endpoint automatically updated to local server.

The mock service will then return the response you configured earlier.

Customizing mock response:

You can customize soap response by adding groovy script in script tab.

Let's add a single line script to retrieve random data each time the request is executed.


${rate} is used in response xml to retrieve data from the script.

This is called a Property expansion and it's a very powerful feature in SoapUI. By inserting a property expansion in any element you can then fill the element programatically. Basically it tells SoapUI to use the current value of property rate.

Execute the request, we could see different response every time we execute.

Congratulations! You have created your first mock test.

140 views0 comments

Recent Posts

See All

Smallest String With A Given Numeric Value

The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.


bottom of page