Open In App

How to Mock REST API’s Using SoapUI

Last Updated : 29 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will see how to Mocking REST APIs Using SoapUI. It is an open-source API Testing tool used for both Simple Object Access Protocol (SOAP) and Representational state transfers (REST) services. It is widely used in enterprise applications for the development, mocking, simulation, and testing of web services. This article provides a step-by-step guideline on how to create a REST Mock Service using SoapUI.

Now let’s see the step below.

Applications Requirement: 

Stepwise Implementation 

Step 1: 

Create a new REST project by clicking on REST present on the Toolbar.

Create REST Project Using SOAP UI

Step 2: 

Specify the URL for the restful Mock service you want to create.

Specify Name for REST Project and click “OK”

The Rest project created is as follows

Step 3: 

In order to create a new mock for the rest project, Right click on the project and click on New REST MockService

New REST MockService

Specify a name for the new mock service and click “OK”

Step 4:

Right click on the mock service and click on Add new mock action

Adding new Mock action

Specify HTTP Method and resource path and click “OK”

Step 5: 

To set a mock response, Right click on the mock action and select New MockResponse.

Add a new Mock Response

Specify Name for Mock Response and click “OK”

Step 6:

Select the Media type. In the content section, specify the response that you want to get on calling the mock service.  Here we are selecting Media type as application/json and json text in Editor as below to test our response:

{
    "Status": "Logged in Successfully",
    "username": "Geeksforgeeks"
}

Content for Mock response

Step 7: 

Double click on the mock service( i.e. Login) to open the mock service editor. Click on the green play button to start the mock service.

Start Mock Service

Now, It specifies the port it is running. The service can be stopped by clicking on the square red button.

Stop Mock Service

Steps in Postman 

Step 1: 

Click on “Micro Services” and then click on “add” button.

 

Step 2:

Select request as “POST”, Enter  your requested URL. and, After that Click “SEND” button.

 

Step 3: 

Now we can see the required request successfully.

 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads