Tutorial on testing webservices with Apache JMeter

This tutorial explains how to build your own Jmeter test and how to send webservice requests and validate the server response.

These days webservices are the preferred way to realize SOA (Service Oriented Architecture). Testing such interfaces in a managed way requires the correct tools. One of the better tools around is Apache Jmeter, an open source application written in Java. An important advantage is the ability to validate the server response against regular expressions. That makes this approach ideal for functional regression testing.


Installing Jmeter

First of all, make sure you have downloaded a recent version of Jmeter. The latest version can be downloaded from http://jakarta.apache.org.

Download the zip binaries and extract them to c:\. Next rename its root folder c:\jakarta-jmeter-2.3.2 to c:\JMeter, so we are both using the same path.

Now we are ready to create a Jmeter test, so launch "\bin\jmeter.bat" to open up the JMeter interface. By default two elements are shown in the left frame.

Test Plan

On the test plan you can define variables yourself and store them for later use. Other performance related settings are available as well, but you won't need them now.


This is just a storage place where you can temporarily put some copied elements. Those items won't be saved when saving your JMeter test. I personally never found use for this element.

Adding elements to the Test Plan

It's time to add elements enabling us to send the webservice request.

Thread Group

--> select "Test Plan" in the left frame, right click, "Add", "Thread Group"

This component defines a pool of users that will execute your test on the server. You only need to update these properties for performance testing but now you can leave them as they are. This component is required when creating webservice requests later on, so don’t delete this one.

HTTP Request Defaults

--> select "Thread Group" in the left frame, right click, "Add", "Config Element", "HTTP Request Defaults"

This element lets you set default values for any following "Request Controllers" and "Webservice Requests". I tend to always use this component as this simplifies your configuration when sending multiple requests in one Jmeter test. Fill in following fields:
Server Name or IP, e.g.:

Port Number, e.g.: 8070

Path, e.g.: /applicationName/webservices/webserviceName

WebService(SOAP) Request

--> select "Thread Group" in the left frame, right click, "Add", "Sampler", " WebService(SOAP) Request"

This component sends the Webservice Request and fetches the response. Of all configuration fields we will only use a few ones:
Filename, e.g.: c:\JmeterTests\MyFirstWebserviceRequest_input1.xml

Memory Cache, uncheck this box

Read SAP Response, check this box, otherwise you won't be able to log the response content of the server

Note: It's important that you uncheck the "Memory Cache" box. If you leave it checked and you change something inside your file to send to the server, JMeter will not send the update. Instead the original version of your file will be used until you close and reopen JMeter.

Make sure the xml in your input file contains a soap envelope. Include your xml content in a soap envelope if this has not been done yet. Probably in that case it will look like this:
<?xml version="1.0" encoding="utf-8"?>
<webserviceFunctionality xmlns........>...</webserviceFunctionality>

If you correctly embedded your xml message in a soap envelope, then your xml file should look like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<webserviceFunctionality xmlns........</webserviceFunctionality>

Now we want to be able to validate the response coming from the server by adding response assertions.
--> select "WebService(SOAP) Request" in the left frame, right click, "Add", "Assertions", "Response Assertion"

On this first response assertion, select "Response Code" as response field to test and select "Matching" as pattern matching rule. Next add a pattern to test by clicking the "Add" button and filling the new pattern to test entry with value 200. By adding this assertion we are sure that the server is up and running. Only functionally testing on the responsetext is not sufficient, as there may be situations in which the assertion result returns true (or OK) while the server is not even running; e.g.: checking that the text response does not contain a certain value.
--> select "WebService(SOAP) Request" in the left frame, right click, "Add", "Assertions", "Response Assertion"

On this second response assertion, select "Text Response" as response field to test and select "Contains" as pattern matching rule. Next add a pattern to test by clicking the "Add" button and filling the new pattern to test entry with any value which you expect the server to return. This makes part of the functional verification. JMeter supports regular expressions, so you may want to use them. Regular expressions are a powerful way of comparing the result text.

Simple Data Writer

Finally we add a control which will write the server response to a file.
--> select "Thread Group" in the left frame, right click, "Add", "Listener", "Simple Data Writer"

Fill in following fields:
Filename e.g.: c:\JmeterTests\MyFirstWebserviceRequest_output.xml

Next click "configure" and thick all checkboxes. This will slow down the performance of your test but this way you will have as much information as possible at your disposition in order to write the response file. If in the future you feel like getting too much information, you can uncheck checkboxes of items you don’t need in your response file.

If you've correctly added all components, your JMeter window looks as follows:

Running the test

Now you're ready to run your test. First save your Jmeter test at a location of your choice. Next select "Start" under the "Run" menu. The test runs until there's no more green light at the right top of your JMeter window. When the test has run, check the server response which has been written to c:\WebserviceTestingOutputFiles\MyFirstWebserviceRequest.xml.

You can add more webservice requests to this test, having their own response assertions and writing their response still to the same output file.
--> select "WebService(SOAP) Request" in the left frame, right click, "Copy", select "Thread Group", right click, "Paste", next move the newly added "WebService(SOAP) Request" on top of your "Simple Data Writer" and select "Insert Before".

If you’ve added more webservice requests to this test, your Jmeter window could look as follows:

If you need help interpreting the server results or with any other aspect of testing webservices with Jmeter, then just drop a note. I'll answer as soon as possible.

Feel free to share your experiences or opinion on this article by adding a comment. Any suggestions / ideas for this or an other tutorial are welcome.

View the FAQ on webservice testing with Apache JMeter

Related Posts by Categories


16 Responses to "Tutorial on testing webservices with Apache JMeter"

Sil said... April 12, 2009 at 1:45 PM

Hi steven, I added a tutorial on file based testing with JMeter (using BeanShell scripting) on my own blog, maybe interessting for your readers too ;)

Sil said... April 12, 2009 at 1:46 PM

I forgot the link of course: http://mytselection.blogspot.com/2009/04/jmeter-to-check-files-and-file-content.html

Steven Machtelinckx said... April 12, 2009 at 10:27 PM

Hello Sil,

Thanks for the link to your interesting article. Keep up the great work!

Anonymous said... October 28, 2009 at 9:12 AM

Hi All,
Need ur help on below query:
How do i attach a file with soap request in J meter.i Have images and pdfs to be attached with every web service request.

Steven Machtelinckx said... October 30, 2009 at 9:10 AM

Personally I don't have experience with sending attachments with a soap request. I did find some information on this topic however. Maybe you should try these links:

1] http://en.wikipedia.org/wiki/SOAP_with_Attachments
2] http://msdn.microsoft.com/en-us/magazine/cc188797.aspx

SoapUI, another webservice testing freeware tool, has a procedure on their website on how to send attachments with SOAP requests using SoapUI. You can find it here:


khadam said... June 10, 2010 at 11:29 AM


I am having issues with getting the respose i want when using Jmeter. I wrap my xml in a soap envelope but i get the folwing fault in the response.

soap:ClientServer did not recognize the value of HTTP Header SOAPAction: .

can anyone help?

Anonymous said... August 15, 2010 at 7:36 PM

Hi all,
To know how to send HTTP request using proxy server click this link.

pradip said... October 26, 2010 at 12:06 PM

looks good

Anonymous said... November 7, 2010 at 10:06 AM

Hi, I am trying to send XML with in SOAP request as one of the element but I keep getting [xX][mM][lL] issue ,then tried removing the encoding with in internal XML ,then I get a response wrapped in SOAP envelope with a blank result which is not expected and I am seeing XAE expceptions on websphere logs,can any one help?

Anonymous said... July 15, 2011 at 7:41 AM

Very nice article.. Keep it up..!

Dzmitry said... August 28, 2012 at 10:14 AM

Thank you for good tutorial. Recently I've found another JMeter Library, have you seen it?


Malla said... March 22, 2013 at 10:54 AM

This is great!


TestWithUs said... May 7, 2013 at 6:25 AM

SWIFT Interview questions on


For selenium solution visit

For QTP interview questions



Kashif Faheem said... November 26, 2013 at 4:38 PM

What would be the best approach to test multiple web services or n number of web services

1- In a single thread group


2- Using n number of thread groups for n number of Web Services

Steven Machtelinckx said... November 27, 2013 at 3:20 PM

Hello Kashif,

It depends :-)

If you have n number of thread groups, then the thread groups will run simultaneously. This can be an advantage or a disadvantage, it depends whether you like/need this. If you put all webservice tests in one thread group, the tests will run sequentially.

Apart from that there's no big difference, it's a matter of preference

India Naru said... December 7, 2013 at 1:11 PM

Read about the most popular books in software testing... Advanced Test Strategy is one among them ..must be useful

Post a Comment

Recent Articles

Top Commenters

Recent Comments