SOAP Service Mocking Overview

The SOAP service mocking feature allows you to simulate a SOAP service by creating a mock service. You can then run it either directly from SoapUI, or use the mockservicerunner.bat (mockservicerunner.sh in OS X) command-line application.

When Mocking is Required

You can use SOAP mock services to perform various tasks:

  • 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.

Note: Please keep in mind that SoapUI mock services are not designed to be implemented as actual live services. Even if a mock service works correctly, it does not mean the actual service built atop of that mock will work as required. It also does not provide any actual functionality except for sending the predefined responses.

Share and Distribute Mocks

If you need to share your mock with other members of your team or even with partners and customers, you can easily save the mock you have created to a WAR file. You can then deploy this WAR mock service in any Java server environment – it will run even without SoapUI.


Share your mocks with 3rd party developers and other teams | Learn more about ReadyAPI (video)


Create Scripts

You can enhance your mocks via scripts. Scripts allow you to simulate almost any behavior, including dynamic results, random errors, responses containing variables, and so on.

Track Test Performance As You Scale Your API Testing

Compare: All SoapUI Pro Features

OpenAPI Specification

SoapUI Open Source

  • Support for SOAP and REST API Testing.
  • Easy multi-environment switching.
  • Detailed test history and test comparison reporting.

SoapUI Pro

  • Support for SOAP, REST, and GraphQL API Testing.
  • Easy multi-environment switching.
  • Detailed test history and test comparison reporting.

Sample SOAP Mock Service

In general, a mock service simulates a live service by exposing a number of mock actions. Mock actions, in turn, contain a number of mock responses.

Let us create a project with a sample mock service:

  1. Select File > New SOAP Project.

    The New SOAP Project menu command

  2. In the dialog that appears, specify a name for your project in the Project Name edit box and enter the following address in the Initial WSDL edit box:

    http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL

    The New SOAP Project dialog

    Click OK.

    Tip: Sometimes, the currency convertor web service we use in this example may be down due to a huge amount of requests. If the Loading Definition window is displayed too long, use any web browser to check the availability of the service – that is, just copy the address, paste it to the address bar, and then try to visit the page.

  3. Once the project you have opened appears in the Navigator, right-click any SOAP interface and select Generate SOAP Mock Service.

    The Generate SOAP Mock Service menu command

  4. The Generate MockService dialog will appear.

    The Generate MockService dialog

    As you can see, SoapUI specifies most of the settings automatically. Click OK.

  5. In the next dialog, specify a name for your new mock service and click OK.

    The Generate SOAP Mock Service dialog

  6. A mock service containing one operation and one request should appear in the Navigator. It is currently inactive. You can edit the mock service before running it – to do that, double-click the name of the mock service.

    The mock service in the Navigator

  7. In the mock service editor, you can see a list of operations of the mock service, as well as request and response logs.

    The mock service editor

    Double-click the operation to see a list of responses associated with it.

  8. Currently, there is only one response.

    The operation editor

    Double-click it to open the response editor.

  9. The response editor is similar to the request editor:

    The response editor

    In the Incoming Request view, you will see the last request sent to the serivce, including the header and attachments.

    To the right, there is the response itself. You can modify its value as you wish – for example, replace ? with "two dollars".

  10. Now you can check if your mock service is working properly. To do that, go back to the mock service editor and click Run. This will start the service.

    The mock service editor: Mock service running

    Tip: To stop the service, click Stop at any time.

  11. 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 Create SOAP Request button in the operation editor

  12. 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.

    The Open Request dialog

  13. After the request editor shows up, you can submit the request by clicking Run. The mock service will then return the response you configured earlier.

    The request and the response in the request editor

  14. Check the response editor – it should now show the request you have sent in the Incoming Request view.

    The request and the response in the response editor

Congratulations on creating your first SOAP mock service!

No one knows APIs better than SmartBear. Find out what our Pro version of SoapUI can do to improve your testing.