Follow by Email

23 Feb 2012

WEBSERVICE (SOAP) REQUEST TESTING USING JMETER



WEBSERVICE (SOAP) REQUEST TESTING USING JMETER
  • Apache Jmeter is java application designed to load test the application. You can use Jmeter to test how much load your Web site can handle.
  • The easiest way to begin using JMeter is to first download Jmeter production release and unzip it. The release contains all of the files you need to build and run most types of tests, e.g. Web (HTTP/HTTPS), FTP, JDBC, LDAP, Java, and JUnit.
To start the jmeter in Windows double click the jmeter.bat file in the bin folder.
To start the jmeter in linux/unix open the file jmeter.sh it is inside the bin folder.

Building a Web Service Test Plan :
  • In this section, you will learn how to create a Test Plan to test a Web Service.
  • You will create five users that send requests to One web page. Also, you will tell the users to run their tests twice. So, the total number of requests is [5 users (no of users) * repeat 2 times(loop count)] = 10 HTTP requests.
  • To construct the Test Plan, you will use the following elements:Thread Group,Web Service Soap Request, and Graph Result.

Adding Users :
  • The first step you want to do with every JMeter Test Plan is to add a Thread Group element. The Thread Group tells JMeter the number of users you want to simulate, how often the users should send requests, and the how many requests they should send.
  • Go ahead and add the ThreadGroup element by first selecting the Test Plan, clicking your right mouse button to get the Add menu, and then select Add --> Thread(s) -->ThreadGroup.
  • You should now see the Thread Group element under Test Plan. If you do not see the element, then "expand" the Test Plan tree by clicking on the Test Plan element.
  • Next, you need to modify the default properties. Select the Thread Group element in the tree, if you have not already selected it. You should now see the Thread Group Control Panel in the right section of the JMeter window
                                
  • In the name field Edit the name based on the testing. Here We are going to test the WebService (SOAP Request). So give the name as SoapRequestThread
  • Number of Threads (Users) are 5
  • Ramp Up period is 1. That means it creates 5 users in 1 second.
  • Loop Count is 2. ie) All users request the service 2 times.
  • If you check the Forever the jmeter repeatedly tests the test plan.

Adding WebService Requests
  • In our Test Plan, we will use a java implemented webservice. Since you're using the webservice sampler, we won't go into the details of writing a webservice. If you don't know how to write a webservice refer some more documentations for creating web service.

  • Start by adding the sampler WebService(SOAP) Request to the SoapRequest element (Add --> Sampler --> WebService(SOAP) Request). Then, select the webservice Request element in the tree and edit the following properties

                        
  • The Name is User choice.
  • Copy the url address of our webservice's WSDL file and paste it in the WSDL URL then click Load WSDL button now the web methods of our webservice is loaded automatically.
  • Then press the Configure button now the protocol, server or IP, Port Number, Path,SoapAction are filled automatically based on your webservice.
  • Now Change the Server Name or IP as localhost.
  • Next inside the Web service Message give the SOAP request for webservice or using browse button load your external soap file.
  • Finally enable the Read Soap Response Check box.


Adding a Listener to View Store the Test Results :
  • The final element you need to add to your Test Plan is a Listener. This element is responsible for storing all of the results of your HTTP requests in a file and presenting a visual model of the data.
  • Select the SoapRequestThread element and add a Graph Results listener (Add --> Listener --> View Results Tree).
  • Next, you need to specify a directory and file name of the output file. You can either type it into the file name field, or select the Browse button and browse to a directory and then enter a file name.
  • Then Click the Start->Run. Now the result of the each user and each request will be generated.
  • Now we can check the sampler result, request and response of each request. If is there any error it will displayed in the sampler result
              
And we can also check Expected result by adding the assertion to the SoapRequestThread (Add -->Assertion-->Response Assertion)

               
Now the response is matches to our expected result.
    

No comments:

Post a Comment