How to test SOAP API with different functionalities of JMeter

14 / Oct / 2015 by Gunjan Sawhney 0 comments

JMeter is a very popular open source tool which is used for load and performance testing. With its multiple features, Jmeter can conduct tests for any web application, web server, mail servers, database or even file servers. A recent requirement for our project made us use different components and elements of JMeter together. In this blog, we will walk you through different elements and features that were used in our test plan to solve this particular use case described below.

Use-case: SOAP API Testing

Recently SOAP APIs were added in our application, so we wanted to test the strength and performance of our servers. Testing the SOAP APIs in Jmeter is very simple. All you need is a SOAP request and the server URL. 

Steps are given below:



Starting with that, we build the first draft of our test plan. One of the requirements was that our servers URLs were not static. Given the condition, we had to modify our test plan so that we can pass variables in our server URL names. Also, SOAP APIs were used to create a user, authenticate it and log out. To accommodate all these requirements in our test case, we used variables, counters, regular expression extractor elements provided by JMeter.

In the next few paragraphs, we would be explaining how to use these three elements in Jmeter.

Illustration 1- User Defined Variables

In the following figure, you can see a config element “User-Defined Variables”. Using this, you can add variables in your script. Here, we have added two Variables “serverA” and “serverB” corresponding to which we have defined the values of our SOAP APIs servers. These two variables are further used in our SOAP API request as URL parameter:

Illustration 2- Counter

The logic behind using the counter in Jmeter is same as in any other programming language/logic. For 5000 users which are created during the test, we needed 5000 email ids to be generated. So, we used JMeter’s Counter config element to solve our problem. As you can see, we have initialized the counter with start parameter value set to 1. The increment value is set to 1 and we have defined the upper limit of 5000:

Illustration 3- Regular Expression Extraction

This “Post Processor” feature of JMeter was then used to extract the session token returned by our authenticate user API. With regular expressions, you can extract for example session tokens, store them in a variable and use them in following requests. The following snapshot describes the same:
Reference: JMeter regular expression extractor

All the elements explained above, were integrated in a test plan to solve our use case. You need to add a listener under the thread group to see the results or output. The below given snapshot contains the desired test plan:



Leave a comment -