Open In App

How to Mock SOAP Web Service Using SoapUI?

Last Updated : 15 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

SoapUI is an open-source testing tool used to test both REST(Representational State Transfer) and SOAP(Simple Object Access Protocol) web services. SoapUI provides the soap service mocking feature which allows to simulate a SOAP-based web service. This helps enterprise-level applications create web service prototypes to test various scenarios without creating the actual service. This feature can be leveraged to set up multiple responses for a mock service with custom HTTP Headers, attachments, and other data to test different incoming requests. This article demonstrates a step-by-step guideline to mock a soap web service:

Stepwise Implementation

Step 1: Create a new SOAP project by clicking on the SOAP icon present in the toolbar as shown below.

Step 1: Create New SOAP Project

Step 1: Create New SOAP Project

Step 2: Specify the project name and the required WSDL Web URL in the appeared dialog box and then click on OK.

Step 2: Name SOAP Project

Step 2: Name SOAP Project

In this example, we are going to name our soap project as TemperatureConversion and make use of below mentioned WSDL Web URL.

Step 3: Expand the SOAP project created and right-click on any soap interface. Click on Generate SOAP MockService to create the mock service.

Step 3: Create New SOAP MockService

Step 3: Create New SOAP MockService

Generate MockService dialog appears which contains operations, path, and port pre-configured for the mock service. Click on Ok to proceed. 

Step 3: Generate MockService Dialog Box

Step 3: Generate MockService Dialog Box

Specify the name of the MockService to be created and click OK. In this example, we are naming the mock service as TempConvertSoap-MockService

Step 3: Name MockService

Step 3: Name MockService

Within the soap project, a soap mock service is created along with a list of operations.

Step 4: Double-click on the mock service to open the mock service editor as below. It displays the list of operations included in the mock service.

Step 4: MockService Created

Step 4: MockService Created

Double-click on any operation to get a list of responses associated with that operation. In this example, we are using the CelciusToFahrenheit SOAP interface.

Step 4: MockService Response

Step 4: MockService Response

Step 5: Double-click on the response to open the Response Editor containing the XML-based response of the web service as shown below.

Step 5: Open MockService Response Editor

Step 5: Open MockService Response Editor

The left side section displays the last incoming request this service has received along with the header and attachment details. On the right side section, the response of the web service is displayed which can be edited. The question mark in the response can be replaced with the value needed to be returned in the response. In this example, we are setting the value to 98.6.

Step 5: Edit MockService Response

Step 5: Edit MockService Response

Step 6: To start the web service, click on the green play button to start the mock service. 

Step 6: Start MockService

Step 6: Start MockService

Once the green play button is clicked, the SOAP MockService starts running as shown below.

Step 6: MockService running

Step 6: MockService running

It specifies the port it is running. The red square button can be used to stop the mock service.

Steps To Test The MockService

In order to check whether the soap service is working properly please follow below steps:

Step 1: Create a new soap request by clicking on the button as shown below.

Step 1: Testing MockService

Step 1: Testing MockService

Step 2: A pop-up dialog appears which allows you to either select an existing request from the dropdown or create a new request. Select the request for the operation to open or create and then click on Ok to proceed.

Step 2: Testing MockService

Step 2: Testing MockService

A Request Editor is opened which can be used to edit the XML-based request of the mock service.

Step 3: Click on the green play button to send the request to the mock service.

Step 3: Click on Green Button to send request to MockService

Step 3: Click on Green Button to send request to MockService

Once the green play button is clicked, a request is sent to the MockService created and we get a response as shown below.

Step 3: MockService Test Completed Successfully

Step 3: MockService Test Completed Successfully


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads