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.

    1. I'm glad that you find it useful. Thanks !

  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. Mẹ cần cung cấp nhiều thực phẩm bổ dưỡng, cân bằng lượng chất, thành phần dinh dưỡng thực phẩm bổ sung dinh dưỡng cho trẻ cho trẻ để đảm bảo lượng dinh dưỡng hấp thu vào cơ thể không bị thiếu hoặc thừa thức ăn đóng hộp cho bé Đối với phụ nữ mang thai việc làm đẹp được nhiều chị em quan tâm làm đẹp da mặt khi mang thai nhưng bên cạnh đó cũng cần phải cần bổ sung nhiều dinh dưỡng trong các bữa ăn hằng ngày bổ sung chất dinh dưỡng khi mang thai nên chú trọng phần vệ sinh cá nhân, tránh gây ra các triệu chứng nguy hiểm ảnh hưởng đến tử cung mang thai có nên dùng băng vệ sinh hàng ngày về việc phụ nữ mang thai có nên dùng băng vệ sinh không là điều thắc mắc của nhiều chị em làm đẹp khi mang bầu mẹ nên chú trọng kĩ hơn vào việc ăn uống, bổ sinh dinh dưỡng, đều đặn theo từng giai đoạn phụ nữ mang thai nên uống bổ sung thuốc gì sử dụng thuốc bổ nhưng cần được qua bác sĩ kiểm chứng.