How to test a RESTful web service using HP’s LoadRunner

Performance Testing Published on:
API Testing Tools

Need to test a RESTful webservice using LoadRunner, but aren't sure if LoadRunner supports RESTFul? Did you try using the Web Services protocol without any luck? Actually, LoadRunner does support RESTful web services using the HTTP/HTML protocol with the web_url function.

Using web_url

REST is a very simple technology that uses XML for communication combined with URL patters. Also RESTFul web services work with most HTTP methods that many services expose. For example:

  • GET is used to perform a query or to obtain data. The data returned from the web service is a representation of the request info.
  • POST can be used to create a new resource. Typically, a web service will respond with data or a status of success or failure.

(For more detail check out this Oracle article on RESTful Web Services)

Using LoadRunners's web_url allows you to GET a request from a RESTFul service using its URL argument.

Using LoadRunner to test a RESTful example

  • For this example, I'll use the Sample Flight Application that comes with Service Test 11.20


  • I'm using the REST URL for my server plus the web service operations with its DepartureCity and ArrivalCity parameters/values. In LoadRunner add a web_url function with the following values:

  • Next, bring up the Run-time Settings enable the Extended Log with all its options:

  • Run the script should return the response from the RESTful service. Your LR's Replay log should contain the response body for the Flights operation:

Modify LoadRunner script

If you wanted to capture the first FlightNumber returned, you would use the same method you would normally use with the web_reg_save_param. The full script should look like this:

Action()

web_reg_save_param(“CheckFlightNum”,
“LB=”,
“RB=”,
“Ord=1”,
“RelFrameId=1”,
“Search=Body”,
“IgnoreRedirections=Yes”,
LAST);

web_url(“xml”,
“URL=http://localhost:24240/HPFlights_REST/Flights?DepartureCity=Denver&ArrivalCity=London”,
“Resource=0”,
“RecContentType=text/xml”,
“Referer=”,
“Snapshot=t1.inf”,
“Mode=HTML”,
LAST);

lr_output_message(“This is the first flightnumber %s”,lr_eval_string(“{CheckFlightNum}”));
return 0;
}

Be Restful with LoadRunner!!

To see how to test a NON-RESTful web service using LoadRunner check out my post How to test a web service using HP's LoadRunner

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
API Testing Tools

15 Top Load Testing Tools for 2022 (Open Source Guide)

Posted on 08/16/2022

In the world of software development, testing is vital. No matter how well ...

What is Throughput in Performance Testing?

Posted on 08/16/2022

Throughput is one of the most misunderstood performance testing concepts new testers sometimes ...

The Ultimate Guide to Performance Testing

Posted on 06/07/2022

Performance matters, especially if you want to produce quality software. For this reason, ...