Testing SOAP/REST Web Services Using JMeter

SOAP is a messaging protocol specification for exchanging structured information in the implementation of web services. Its purpose is to induce extensibility, neutrality, and independence. It uses XML Information Set for its message format and relies on application layer protocols.

SOAP is used in a variety of messaging systems. It is delivered via a variety of transport protocols and the initial focus of SOAP is remote procedure calls transported via HTTP.

I am gonna explain how to test these kinds of web services via, open source, Apache JMeter testing tool. We’ll use a simple calculator web services as an example. You can do simple Add, Subtract, Multiply and Divide operations.  http://www.dneonline.com/calculator.asmx

GET REQUEST METHOD

1.Open Apache Jmeter.

2.Click the Template button.

3. Select the “SOAP Webservice Test Plan” from the select template dropdown.

4. Click “Create” Button

5. Enter below information in HTTP Request sampler:

Protocol: http
Server Name or IP :www.dneonline.com
Path: /calculator.asmx
Method:GET

6. Run your test and you will receive a response from the web service and GET request will fetch the data and return “200” code.

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.

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

1.Enter below information in HTTP sampler :

Protocol: http
Server Name or IP :www.dneonline.com
Path: /calculator.asmx
Method:GET
Header:Content-Type text/xml; charset=utf-8
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>

<Add

xmlns="http://tempuri.org/">

<intA>20</intA>

<intB>5</intB>

</Add>

</soap:Body>

</soap:Envelope>

2.Now add Response Assertion to verify the web services response,Right click on HTTP Request – Add – Assertions – Response Assertion and enter pattern to verify from Web Service Response.

3. Run the test and Next go into “View Result Tree” Listener is possible to verify sample response.

Select the sample on left panel and choose XML visualization (as shown in above picture). Into response detail we can see response structure and data returned.

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

Categories: Uncategorized

Tagged as:

2 replies »

  1. Thank you Mohd Nazim. I have never worked on SOAP and was able to directly implement a request into my project referring this blog.
    Many thanks!!

Leave a Reply