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:

(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


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