{"id":28048,"date":"2015-10-14T10:35:14","date_gmt":"2015-10-14T05:05:14","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=28048"},"modified":"2015-10-14T11:13:53","modified_gmt":"2015-10-14T05:43:53","slug":"how-to-test-soap-api-with-different-functionalities-of-jmeter","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-test-soap-api-with-different-functionalities-of-jmeter\/","title":{"rendered":"How to test SOAP API with different functionalities of JMeter"},"content":{"rendered":"<p>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\u00a0even file servers. A recent requirement for\u00a0our project\u00a0made us use different\u00a0components 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\u00a0use case described below.<\/p>\n<h3><strong><span style=\"color: #ffa500;\">Use-case: SOAP API Testing<\/span><\/strong><\/h3>\n<p>Recently\u00a0SOAP APIs were added in our application, so we wanted to test the strength and performance of our servers. Testing\u00a0the SOAP APIs in Jmeter is very simple. <strong>All you need is a SOAP request and the server URL.\u00a0<\/strong><\/p>\n<h3><strong><span style=\"color: #ffa500;\">Steps are given below:<\/span><\/strong><\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28082\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/threadgroup.png\" alt=\"threadgroup\" width=\"1085\" height=\"629\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28096\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/soap11.png\" alt=\"soap1\" width=\"1085\" height=\"630\" \/><\/p>\n<p>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.<\/p>\n<p>In the next few paragraphs, we would be explaining how to use these three elements in Jmeter.<\/p>\n<h3><strong>Illustration 1- User Defined Variables<\/strong><\/h3>\n<p>In the following figure, you can see a config element &#8220;User-Defined\u00a0Variables&#8221;. Using this, you can add variables in your script. Here, we have added two Variables &#8220;serverA&#8221; and &#8220;serverB&#8221; 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:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28092\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/userdefingvar.png\" alt=\"userdefingvar\" width=\"1088\" height=\"636\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28094\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/userdfigvar2.png\" alt=\"userdfigvar2\" width=\"1087\" height=\"636\" \/><\/p>\n<h3><strong>Illustration 2- Counter<\/strong><\/h3>\n<p>The logic behind using the counter in Jmeter is same as in any other programming language\/logic. For\u00a05000 users which are\u00a0created during the test, we needed 5000 email ids to be generated. So, we used JMeter&#8217;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:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28109\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/Counter1.png\" alt=\"Counter\" width=\"1091\" height=\"632\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28111\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/countersoap.png\" alt=\"countersoap\" width=\"1088\" height=\"637\" \/><\/p>\n<h3><strong>Illustration 3- Regular Expression Extraction<\/strong><\/h3>\n<p>This &#8220;Post Processor&#8221; 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:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28113\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/regex1.png\" alt=\"regex1\" width=\"1085\" height=\"641\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28130\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/outputsessionID.png\" alt=\"outputsessionID\" width=\"1090\" height=\"639\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28124\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/regextrue.png\" alt=\"regextrue\" width=\"1088\" height=\"639\" \/><br \/>\n<a href=\"http:\/\/jmeter.apache.org\/usermanual\/regular_expressions.html\">Reference: JMeter regular expression extractor<\/a><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28150\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/lastregex1.png\" alt=\"lastregex\" width=\"1087\" height=\"640\" \/><\/p>\n<p>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:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-28155\" style=\"border: 1px groove #545565;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/10\/final1.png\" alt=\"final\" width=\"1087\" height=\"636\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u00a0even file servers. A recent requirement for\u00a0our project\u00a0made us use different\u00a0components and elements of JMeter together. In this blog, we will walk [&hellip;]<\/p>\n","protected":false},"author":204,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":7},"categories":[1],"tags":[2566,2567],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/28048"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/204"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=28048"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/28048\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=28048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=28048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=28048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}