WebServices LoadTesting Using Jmeter
Before starting Jmeter Webservices testing we need to keep below information handy for :
1. XML/XMLs required for the flow
2. URL where the SOAP/XML-RPC Request
Let us Create a new order using webservice:
1. Create a Test Plan
2. Add a Thread Group
3. Add Sampler -> SOAP/XML-RPC Request as shown below:
SOAP/XML-RPC Request sampler sends a SOAP request to a webservice. It can also be used to send XML-RPC over HTTP.
4. Fill the required details in URL and SOAP/XML-RPC Data (XML) in the Request as shown below:
In this XML we have some fields which are unique and need to be changed every time we send the request else it will fail as duplicate record as below:
“There is an ongoing Customer Order with the same Customer Order ID”
We will bring uniqueness to the record in 2 ways:
1. Using the Data generated in a CSV file
2. Using a Beanshell sampler and change the Parameters in the xml
Method 1:
1. We will create a CSV file with the required data (may be Manual entry of the required format) and store it.
2. We have 3 fields which are required to be unique for creating an order.
3. The fields are as below defined in CSV Data Set Config:
<core:value>${LOCATION_ID}</core:value>
<core:value>${CUSTOMER_ID}</core:value>
<core:value>${PHONE1}</core:value>
5. Once done if we run the test we can view in the Result Tree that the request passed as below :
Below is the Test Plan along with the Result.
Method 2:
In this method we will use a Beanshell Sampler to generate a random value for the required fields and replace them in the XML.
We will use timestamp and a unique postfix generated using a counter:
We have counter defined as below:
In Beanshell Sampler we had the below code:
The XML is same as used in Method 1.
Run the Thread and check in the View Results we have the below :
This is how we can run Webservices in Jmeter.
In the above methods, in case there is change in the XML we need to modify the SOAP/XML-RPC Request everytime.
Comments
Post a Comment