Simple Mock Service from WSDL using SoapUI

Service virtualization is the new buzz word of the industry now a days and since we are in SOA world as it is, virtualizing web services is a must have for any organization. In this article, we are going to take a look at how to create a simple mock service from WSDL using SoapUI.

Contents of this article are

Understanding the Service to Mock

In order to mock a simple service, we need to understand the service we are trying to virtualize. For our article, we are going to use a publicly available Currency converter webservice available on

Main things to note about this service are:

  • The Service WSDL is available here
  • The Service provides an operation called conversion rate which takes from currency and to currency details and returns the conversion rate
  • Some of the valid currency values to be used for input are USD, GBP, INR, etc 

Creating SoapUI project and Mock Service

Creation of Asynchronous test case could be divided into three main sections namely:

  1. Create SoapUI project & Mock Service
  2. Configure Mock Service to return response
  3. Test Mock Service

Create SoapUI Project & Mock Service

Creation of SoapUI project & Mock Service is a straight forward process.

  • First create a new SoapUI project by importing the WSDL
  • Make sure to have the create mock service option checked to automatically create mock service for the imported WSDL
  • Configure the port and end point details for the mock service for each of the SOAP and Soap12 bindings
  • Name the mock service name to be created

Note that this section is pretty straight forward since you can use the default options for auto generating artifacts.

Detailed steps for creation of SoapUI project and test case is shown in the Image Show below

Configure Mock Service to return response

Steps involved in configuring mock service to return appropriate response is as follows:

  • Modify the Response 1 generated under mock service -> mock operation name to return appropriate SOAP response back to the caller
  • Rename the response correctly for better management of mock service
  • Clone the response and create additional responses as needed for the mock service
  • In our example, we will create a simple USD to INR response and a GBP to INR response for our mock operation

Walk through of the above process with detailed steps are provided in the below image show

Test Mock Service

Steps involved in testing the mock service are as follows:

  • Make sure that the mock service is running. If it is not running already (you can know if the service is running or not by looking at the green icon of mock service in the navigator – which should be moving if the service is running!!), right click the mock service and select the option to start minimized
  • Modify the conversion service input request to have USD and INR as from and to currency values. Point the request to the mock service end point and run
  • You should see the response that you had saved under USD to INR before. If you have also created GBP to INR response, then the response for your request should alternate between one and the other.

Walk through of the above process with detailed steps are provided in the below image show

Understanding the Mock Operation

By double clicking the Conversion Rate mock operation under the mock service, we see that there is a dispatch rule of SEQUENCE automatically set for this operation. What the SEQUENCE rule does is to send the responses stored under the mock operation in a round robin fashion back to the caller. For example, first request will get “USD to INR” response and the next request will get “GBP to INR”. Note that in this dispatch rule, you cannot configure the response to be based on request – like

  • If the from currency is USD and to currency is INR then send USD to INR response
  • If the from currency is GBP and to currency is INR then send GBP to INR response

Simple mock service image walk through

Create a new SOAPUI Project

Picture 2 of 18

Create a new soapUI project by right clicking workspace and selecting new project


Some of the things to conclude from this example are:

  • SoapUI provides an easily way of creating simple mock service based on WSDL
  • For a quick static simulated service, the amount of effort involved is very trivial
  • There are other dispatch rules provided with SoapUI other than SEQUENCE like QUERY_MATCH, XPATH, SCRIPT for more advanced behaviors
  • For creating a virtual service WSDL is required in SoapUI – ie. if you just have request and response pairs, you can’t generate mock services
  • SoapUI as the name suggests mainly deals with virtualization of SOAP services

Share this:

About Chethan

I am the Founder and Director of! I am an Entrepreneur, Architect, Problem Solver & Techy - All rolled into one!!