Loadrunner Web Services Tutorial Scripting In Two Ways
By Sam Z // Wednesday, April 09, 2014
Web Services in loadrunner: We can do web services scripting in two ways:
By using Web Services Protocol. (Need additional License)
By using Web Protocol.
Scripting Using Web Services Protocol:
I have taken weather web service as example shown in this link.
Steps:
First open the vugen and select Web Services protocol.
Click on Manage Services on top nav bar and Click on Import and give the WSDL URL which is usually ends with wsdl
http://www.webservicex.net/globalweather.asmx?WSDL.
Now Click on Add Web Service Call on top nav bar. Give the Input Arguments and Leave the out put arguments empty. And click on ok. As shown in the following image.
Input Arguements in Web Services
It will create a script in loadrunner as shown below. You can perform the steps one by one in this way for all the web services steps. You can use lr_xml_find and lr_xml_get_values to validate the page.
web_service_call( "StepName=GetCitiesByCountry_101", "SOAPMethod=GlobalWeather|GlobalWeatherSoap|GetCitiesByCountry", "ResponseParam=response", "Service=GlobalWeather", "ExpectedResponse=SoapResult", "Snapshot=t1396977083.inf", BEGIN_ARGUMENTS, "CountryName=India", END_ARGUMENTS, BEGIN_RESULT, END_RESULT, LAST);
Using Web Protocol:
We can create the same request using Web (HTTP/HTML) protocol. You need take the xml request as shown in the following and place in the web custom request.
XML Request Example for Web Custom Request
You need to keep this soap request in the web request body. As shown below and you can capture all the response using correlation function. You can also add check point using web_reg_find. The url should end with .asmx as shown in the request.
web_reg_find("Text/IC=New Delhi", LAST); web_reg_save_param_ex( "ParamName=Web Service Response", "LB=", "RB=", SEARCH_FILTERS, LAST); web_custom_request("Weather SOAP Request", "URL=http://www.webservicex.net/globalweather.asmx", "Method=POST", "TargetFrame=", "Resource=0", "RecContentType=text/xml", "Referer=", "Mode=HTML", "EncType=text/xml; charset=utf-8", "Body= Your Request should be here as shown in the following image" LAST);
Web Custom Request with Web Services