How to create a SOAP API request in JMeter

Apache JMeter is an open-source load-testing tool that can also be used for performance testing like volume, stress, scalability, reliability, and capacity testing.

Creating a SOAP API request in JMeter is a bit technical because the structure of the request must be correct and follow the SOAP request rules. SOAP API requests should include the following components:

  • URL of the service: The host of the request (www.domain.com), port number (if any), and the path of the URL (/service/).

  • Payload: The XML body of the request.

  • Request Header: To define the request's content type, SOAPAction, and authorization protocol. SOAPAction is required only for .Net services, so it can be removed or left blank for other web services.

In the previous versions of JMeter, there was a separate sampler for SOAP requests, but now it has been deprecated, and the "HTTP Request" sampler is used for SOAP requests too. There are many free SOAP web services available, and for this topic, we are using DataFlex web service for country information.

Click the "Run" button in the widget below, and after some time, you'll see the JMeter application loading in the "Output" tab of the widget. Click the link after the text "Your app can be found at:" and the JMeter application will open in the new browser's tab.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ListOfContinentsByName xmlns="http://www.oorsprong.org/websamples.countryinfo">
    </ListOfContinentsByName>
  </soap:Body>
</soap:Envelope>
JMeter Application

Follow the steps below to create a SOAP API request to DataFlex web service

  1. Right-click the "Test Plan" in the right panel, and select "Add" -> "Threads (Users)" -> "Thread Group". It'll add a new thread group in which the properties of the thread are configured. We are leaving all the options to their default values.

  2. Right-click the "Thread Group" and select "Add" -> "Sampler" -> "HTTP Request". It'll add an "HTTP Request" under the "Thread Group", and we need to define our SOAP API request in this module. Write the following values for the specified fields:

    1. Server Name or IP: webservices.oorsprong.org

    2. Path: /websamples.countryinfo/CountryInfoService.wso

    3. HTTP Request: POST

    4. Click the "Body Data" tab, and type the XML code given in the index.xml file in the editor. This code will return a list of continents.

  3. Right-click the "Thread Group" and select "Add" -> "Config Element" -> "HTTP Header Manager".

  4. Once the header manager is added, click the "Add" button at the bottom of the page.

  5. Write Content-Type in the "Name" column, and text/xml; charset=utf-8 in the "Value" column. Authorization details and SOAPAction are added here. Since we are accessing public web services and it is not a .Net service, we don't need them.

  6. Right-click the "Thread Group" and select "Add" -> "Listener" -> "View Results Tree". A listener is used to view the result of the API request.

Once everything has been added, click the top menu bar's green "Start" button to start the API execution. The result will be available in the "View Results Tree" module.

Copyright ©2024 Educative, Inc. All rights reserved