Friday 4 September 2015

Creating Web Services Script in LoadRunner using WebService/Web(http/html) Protocol

Some Important Definitions:

Web Services:
It is a web application components which can be published & used on web.
Web services do not require the use of browsers or HTML.
In Web Service XML is used to tag the data, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available.

XML: EXtensive Markup Language
XML is designed to describe the data & act as a tool for carrying information.

SOAP: Simple Object Access Protocol
It is a protocol for accessing web services.
Soap is a format for sending messages & used for communication between applications.

WSDL: Web Services description Language
It is an XML document which is used to describe & locate web services.
It specifies the location of the service and the operations (or methods).


Data requirements:

  • Sample Request & Response XML.
  • End Point URL(Host) where request xml to be posted. E.ghttp://webservice.nam.nsroot.net/
  • WSDLfile to get the information & soap action for all the existing operations/methods.
  • Operation details which needs to be invoked like “GetLoadDetails”.
  • SSL Certificate(also known as a Web Server Certificate, Secure Server Certificate, and Digital Certificate) & password if the host is SSL secured.
Two different ways of creating Web Services Script:

We can do web services scripting in two ways:
  • By using Web Services Protocol.
  • By using Web(HTTP/HTML) Protocol.
Steps for writing script:

  • Open the Vugen and select Web Services protocol.
  • Click on Import SOAP on top navigation bar and select request xml file.
  • Click LOAD and provide End Point URL(Host) & Soap action then press OK.
  • Soap request will be created with the step name “SOAP Request”.
Error Handling & Validation:
lr_xml_find and lr_xml_get_valuesfunctions can be used to validate the page. If-Else statement can be used to validate the resposne.
Example:
lr_xml_find("XML={response}",
"Query=//SOAP-ENV:Body/*/LoanAmount",
"Value=2000",
LAST );
lr_xml_get_values("Xml={response}",
"Query=//SOAP-ENV:Header/*/UUID",
"ValueParam=UUID",
LAST);
Error Handling:
if (strcmp(lr_eval_string("{Response}"), "0") != 0 )
{lr_end_transaction (“Submit_Request", LR_FAIL);
LR_EXIT_ITERATION_AND_CONTINUE;
lr_error_message(“Invalid Response"));
return 0;
}
else
{lr_end_transaction ("Submit_Request ", LR_PASS);
}


Writing Script in Web(http/html) protocol:
We need to create Custom request using Web protocol & keep the xml request in the web request body.
Example:
web_custom_request("Weather SOAP Request",
"URL=http://www.webservice.nam.nsroot.net/GetLoanDetails",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=text/xml",
"Referer=",
"Mode=HTML",
"EncType=text/xml;charset=utf-8",
"Body=<<Your Complete XML Request>>"LAST);

We can capture complete response or any particular value using web_reg_save_paramfunction.
Check point can also be added using web_reg_findfunction.
If-Else statement can be used for error handling check.

Examples:
web_reg_find("Text/IC=ResponseCode>0<",LAST);

web_reg_save_param(“Complete_Response",
"LB=",
"RB=",
"NOTFOUND=warning",
"SEARCH=ALL",
"ORD=1",
LAST );



1 comment:

  1. the blog is very nice and interesting. thank you for sharing the blog with us. keep on updating.
    Software Testing Training in Chennai

    ReplyDelete