JMeter Web service API Test Plan
Before proceeding with this section, let us first understand some of the key concepts regarding Web Services API.
Web services are defined as a software system designed to support interaction between two machines over a network. It is designed to have an interface that is depicted in a machine-processable format usually specified in Web Service Description Language (WSDL). Typically, "HTTP" is the most commonly used protocol for communication. Web service also uses SOAP, REST, and XML-RPC as a means of communication.
A Web service might not contain a complete set of specifications and sometimes might not be able to perform all the tasks that may be possible from a complete API.
API (Application Programming Interface)
An API acts as an interface between two different applications so that they can communicate with each other. It is a method by which the third-party vendors can write programs that interface easily with other programs.API may use any means of communication to initiate interaction between applications. For example, the system calls are invoked using interrupts by the Linux kernel API.
An API consists of a complete set of rules and specifications for a software program to follow in order to facilitate interaction.
A Web API can be considered as a development in web services where emphasis has been moving to simpler representational state transfer (REST) based communications. Restful APIs do not require XML-based web service protocols (SOAP and WSDL) to support their interfaces.
Web services are broadly classified in two categories:
For our test purpose we will be using some publically available REST API's to test with JMeter.
You can search for various publically available REST API?S on the internet and get the API key to set up a test in JMeter. You can also build an entire Web Service Project using any development environment and deploy it on JMeter to run a test plan.
For this test, we are using API provided by Open Weather Map website under the URL:
The following image shows the API section provided by Open Weather Map website.
You can sign-up on this website to get access to your API key which is subsequently used to get the proper weather reports.
In our case, we have generated our API key as: 3f25ec8eed9e1951e21407a34312c2c8
The following image shows the generated API key after successful login.
Now, we will use this API key along with the method to call API to get the desired results. The method to call an API includes the server name followed by the city code/city name and API key.
The following image shows an example of an API call provided by OpenWeatherMap website.
Now, we will create a Test Plan to test REST API provided by the OpenWeatherMap website.
Create JMeter Test Plan
Modify the following properties of the thread group:
Set up the following fields in the HTTP Request control panel:
appid = 3f25ec8eed9e1951e21407a34312c2c8
The Listener element will be responsible for storing all of the results of your HTTP request in a file and presenting a visual model of the data.
Save and Execute Test Plan
Verify the Output
The following output can be seen in the listener.
In the Response data tab, you can see the actual weather report provided by OpenWeatherMap website.