Friday 8 August 2014

Webservice Testing Using Jmeter



Web Service Project with JMeter

a. SOAP UI Test
Before we configure web service in JMeter, configure and test it in SOAP UI. Make sure that the web service which is intended to be performance tested, is giving you correct response in SOAP UI. As we will be using SOAP UI request XML in JMeter to test the same.
Please find below sample SOAP UI screen shot. 


b. Configure Web service (WSDL) in JMeter 

i. Add Thread Group 

After you open JMeter, right click on Test Plan to add “Thread Group” wherein web service will be added further. Please see below snap shot. 

 


Thread group will define the nature of your performance test and will execute the added web service accordingly.

Number of Threads(users) : Specify number of concurrent users which are going to access this web services simultaneously. Be very sure when you calculate concurrent users. Any incorrect information entered would lead to UN-realistic test and results as well.

Ramp up Period: The ramp-up period tells JMeter how long to take to "ramp-up" to the full number of threads chosen. If 10 threads are used, and the ramp-up period is 100 seconds, then JMeter will take 100 seconds to get all 10 threads up and running. Each thread will start 10 (100/10) seconds after the previous thread was begun. If there are 30 threads and a ramp-up period of 120 seconds, then each successive thread will be delayed by 4 seconds

Loop Count : Be default loop count is 1, which means each thread(user) will execute the web service only ONCE. You can change this setting as per requirement. 



ii. Add Web Service to JMeter 

Add “WebService(SOAP) Request (DEPRECATED)” in Thread group and rename it to your web service name. 







iii. Enter web service (WSDL) details 

WSDL URL:
Enter the WSDL file link (make sure you write ?WSDL at the end of link) in the text box and click on “Load WSDL” button. It will populate all its subsequent methods in “Web methods” drop down list. Sometimes the “Web methods” drop down list will not be populated.
Please see below screen shot.





Note: If WSDL file is on your machine, then please give complete path of WSDL file in following format. Please add file:/// before the actual wsdl file path.
For Exp: file:///D:/JMeter/bin/file.wsdl

 
Click on Configure Button: Select your web service from down list and Click on “Configure” button which will load web service details on the screen along with its SOAP ACTION 



NOTE: If drop down list is not populated, still click on “Configure” button which will populate the details on screen and add SOAP ACTION from SOAP UI.
Take SOAP Action from SOAP UI.
Simply do a “Ctrl+C” from SOAP U and “Ctrl+v” in JMeter
  







Enter SOAP Request XML:
Copy the request XML from SAOP UI and paste it in JMeter Web service Message text box.
Copy from SOAP UI:
Paste it into JMeter:
Also check the “Read SOAP Response” check box, which will help in checking the response of web service at the time of debugging.
At this moment, your web service is configured successfully in JMeter. Now run the web service for 1 user and check the response using Listener.
  








iv. Rerun the script to debug 

Rerun the web service (script) for 1 user and check the response using Listener.
Listeners are used to listen to the response of the execution. There are different types of listener available. And “View Result in a Tree” is a listener very useful for debugging purpose.
Please see below on how to add listener. 


Please make sure that in Thread group, you are running for 1 users and 1 loop count to debug.
Click on Run Button to run the web service for 1 user and check the response in listener.
Change the file format from drop down list shown below to see response in respective format. Green Icon indicates correct response. Red will indicate error.

 
Please save your test plan before you proceed further. It will be saved as ”.JMX” file.
As this moment web service is configured, but you are still not in a position to run a performance test.
Please do following things with your script before you are in a positing to run the performance test.
ü Assertion
ü CSV data set config
ü Timer
ü Listeners

1 comment: