Saturday, April 6, 2013

Web Services Performance Testing with JMeter

This article explains how to measure the performance of your JEE6 web services with JMeter.

Web Service

The web service is a trivial one, that echoes its text input as illustrated by the following code:
package org.javabenchmark;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService(serviceName = "EchoWebService")
public class EchoWebService {

    public String echo(@WebParam(name="text") String text) {
        return "Echoing: " + text;

Use your favorite JEE6 application server (Glassfish, JBoss, TomEE, Weblogic, WebSphere, ..) to deploy a simple application that exposes the previous web service (this step is beyond the scope of this article).

The endpoint of the service can be constructed by concatenating the application's context and the name of the service. For instance, if the application is deployed to http://localhost:8080/jee6, then the web service endpoint will be: http://localhost:8080/jee6/EchoWebService

JMeter Installation

First, you need to download JMeter there. Next, you need a mandatory JMeter plugin : jmeter-plugins.

Unzip the JMeter archive. Copy the JMeterPlugins.jar file of the plugin archive in the lib/ext directory of your JMeter installation directory.

Test Plan

Now, you are ready to generate some SOAP requests. To achieve this, launch JMeter, right click on the Test Plan icon and choose Add > Threads (Users) > jp@gc - Stepping Thread Group :

Then, set the number of threads to 30, to enable 30 concurrent threads as illustrated below:

So, the performance test will start 10 threads, then waits 30 seconds, and starts again 10 threads until reaching 30 threads. Then it will hold the load for 1 minute.

To invoke the web service we need to set the content type and a SOAP envelope to call the service.

First, add a HTTP Header Manager to set the content type : right-click on the Stepping thread group and choose Add > Config ElementHTTP Header Manager.

Then, click the Add button at the bottom and fill the first row of the HTTP Header table with the following values :
  • Name column: content-type
  • Value column: text/xml

To execute the call to the service web, a HTTP request sampler is needed : right-click on the Stepping thread group and choose Add > Sampler > HTTP Request.

Next, configure the HTTP Request sampler like this:

  • implémentation : HttpClient4
  • Method: POST
  • Path: http://localhost:8080/jee6/EchoWebService (replace with your endpoint address)
  • Post Body:

TEXT ${__counter(FALSE)}

Replace the previous XML with the one corresponding to the web service you are testing. You can use the WSDL and the XSD provided by the service. In our case, both are given with the following addresses:
(adapt those URLs with the ones provided by your application server)

To check that everything goes right, add a View Results Tree sampler : right-click on the Stepping thread group and choose Add > Sampler > View Results Tree.

So, the next step is to verify that the test plan runs correctly and that the web service is responding (your web service must be up and running):

  • Click the start button:

  • And check in the view results tree that every request succeeds:

EDIT: Do not use the View Results Tree during the load test. Just click the Error check-box or disable the Results Tree.

Everything is fine, so it is time to collect some metrics about the performance of the targeted web and to achieve this, we need to add some listener to our test plan:

  • Response time: right-click on the Stepping thread group and choose Add > Listener > jp@gc - Response Times Over Time.
  • Request per second: right-click on the Stepping thread group and choose Add > Listener > jp@gc - Transactions per Second.
  • Response time's Percentiles: right-click on the Stepping thread group and choose Add > Listener > jp@gc - Response Times Percentiles.

It is up to you to pick up from the numerous listeners available !


The last step is to start again the test plan and to monitor graphs provided by the 3 listeners previously added:

Response times
Requests per second

Response times percentiles


  1. Nice article, 2 important points although:
    - Never use View Results Tree during the real Load Test
    - Prefer NON GUI Load testing


  2. Thanks for your advice ! Usually, i only use the View Results Tree to display errors that may occur during the load test.

  3. you can capture the errors in simple data writer and opt for non-gui based tests as JMeter UI eats up a lot of memory.

  4. Also instead of using these listeners for analysis u can use commands to generate graphs. You will find these commands on google code portal

  5. Nice article! Regarding the results, I was wondering why few requests takes 45ms, 10 times more than the normal response time. ?

    1. Those 2 spikes in the response time chart result very probably from some garbage collector activity that occurs during the load test.

  6. Excellent Post. Also visit

  7. Thanks for your great information, the contents are quiet interesting.I will be waiting for your next post. website development company

  8. Great article. It really helped me.

  9. The article is very clear and easy to read and understand, thanks. For ones who need test REST web services (the ones who talk JSON) - Testing SOAP/REST Web Services Using JMeter may be helpful

  10. Can we test secure web services this way? I have tried all possible options for importing the certificates into keystore, playing with JMeter system properties file, but the tool fails to append the security headers that should be sent alongside the envelope. Let me know if you have any info. Thanks!

  11. wow! thanks man for sharing this conversation here is lots to learn in it about web development techniques again thanks and keep us update as you always. :)Official Blog

  12. Thanks regarding sharing the valuable AS WELL AS very informative blog Promotion King

  13. A happy visitor is always a returning visitor. And finally, your website would be able to exploit the latest features in safety and security, data collection, content presentation and more.
    Web guy

  14. I would like to thank you for your nicely written post, its informative and your writing style encouraged me to read it till end. Thanks!
    limo service va

  15. The post was really awesome. within the small blog you have included so many things within the small blog. Load Test Website

  16. Thank you for sharing this. It was a great guide on how to blog properly. Articles you have it is very clear and detailed here. Look forward to your writing in the future..
    Limousine in Washington dc


  17. The information and the aspect were just wonderful. I think that your viewpoint is deep, it’s just well thought out and truly incredible to see someone who knows how to put these thoughts so well. Good job! Website Monitoring Tools


  18. This is genuinely an awesome read for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
    Web Development

  19. exceptionally hesitant to enlist another person because of a paranoid fear of a similar thing happening once more.Edknt Media

  20. Just can’t help to think, how a person can write such amazing stuff.
    software development company in delhi

  21. Web development in Australia may be a relatively younger industry as compared to the major players like US, India, and China, but this does not rue in the potential of the upcoming IT industry from the country down under. skrajučių gamyba

  22. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also Webdesign

  23. You can utilize CSS to supplant pictures,web development services company which is another website design pattern that is probably going to stick around for the long time. It would be a disgrace, however, for HTML5 use to turn into another Flash.