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

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
Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.
Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.
With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.
He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.
Follow him on LinkedIn or check out more at TestGuild.com.
Related Posts
Look, I’ve been doing automation testing including performance testing for over 25 years. And in that time, the #1 question […]
Look, performance testing has the biggest gap between “we should really do that” and “we actually do that” of any […]
Regarding e-commerce, Black Friday is the ultimate test of endurance. It’s one of those days of the year, along with […]
DevOps Toolchain Podcast with Joe Colantonio With the current demand for software teams to high quality product in a timely […]



