Jul. 7th, 2015

Testing SOAP/REST Web Services Using JMeter

The Representational State Transfer (REST) uses the HTTP request method, and the most popular  are GET, POST, PUT and DELETE. Responses to these requests return status codes indicating success or failure as well as any applicable headers, and JSON representing the affected fields (or nothing) in the message body. The following sections describe how you can easily write a JMeter script with one of these methods.

 

GET REQUEST METHOD

 

1. Add an HTTP Request to your Thread Group.

 

2. Fill in the Server Name or IP, path, and choose GET method.

    For example, we use validate.jsontest.com as Server Name and ‘/’ as path

 

3. If your API request contain query parameters, you may specify it in path (for example, ‘/?json=[1:1]’) or in Parameters area:  

 

Name: json

Value: [1:1]

 
Testing SOAP/REST web services using JMeter:GET_withParameters
 

4. Add View Results Tree, and run your script. The following show the Sampler result, Request, and Response data. 

 
BlazeMeter Soap Test View Results Tree
 

POST REQUEST METHOD 

 

In POST requests, you can fill in both the body and the headers. You can also specify query parameters in path. The HTTP headers, which contain metadata, are tightly defined by the HTTP spec. They can only contain plain text and must be formatted in a certain manner. To specify headers, you’ll need the HTTP Header Manager, and the most common headers are Content-Type and Accept.

 

- The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient.

 

- Accept can be used to specify certain media types that are acceptable for the response. You can use a user agent to simulate different browsers' behaviors.

 

Post Body can be useful for the following requests: GWT RPC HTTP, JSON REST HTTP, XML REST HTTP, and SOAP HTTP Request.

 

For instance, we use the server name: www.webservicex.net:

 

Path: /periodictable.asmx

Body: 

<?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/">

  <soap:Body>

<GetAtoms xmlns="http://www.webserviceX.NET" />

  </soap:Body>

</soap:Envelope>

 

And header: Content-Type: text/xml

 
Rest/Post with JMeter
 

You can configure other requests (similar to GET and POST) using required methods, path, parameters, or body and headers. 

 

PLEASE NOTE THAT THE WEBSERVICE (SOAP) REQUEST IS ACTIVE IN JMETER 3.0. SOAP/XML-RPC REQUEST IS ACTIVE. PLEASE USE THE HTTP_REQUEST INSTEAD.

Result of SOAP request - find them in View Result Tree.
 
 
 
 

The following shows the results of the HTTP request test:

 
SOAP tests using JMeter:BlazeMeter Load Results
 

LEARN MORE

View our free on-demand webcast, Load Testing REST APIs in JMeter

 

Be sure to read through all our JMeter tutorials!

 

You can also learn how BlazeMeter brings JMeter to a whole new level.  Finally, you can request a 1-on-1 demo with our performance engineers to learn about JMeter, BlazeMeter and performance testing. 

 
 
 

Interested in writing for our Blog? Send us a pitch!