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.
Step 2:
Specify the URL for the restful Mock service you want to create.
Step 3:
In order to create a new mock for the rest project, Right click on the project and click on New REST MockService
Step 4:
Right click on the mock service and click on Add new mock action
Step 5:
To set a mock response, Right click on the mock action and select New MockResponse.
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" }
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.
Now, It specifies the port it is running. The service can be stopped by clicking on the square red button.
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.