Professional Documents
Culture Documents
Web
Services
allows
different
applications
from
different
sources
to
communicate with each other without time-consuming custom coding, and because
all communication is in XML, Web services are not tied to any one operating
system or programming language.
1.2 Web Service Building Blocks
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.
Thus XML + HTTP form the basic Web services platform. The HTTP protocol is the
most used Internet protocol. XML provides a language which can be used between
different platforms and programming languages and still express complex messages
and functions. It allows designers to create their own customized tags, enabling the
definition, transmission, validation, and interpretation of data between applications
and between organizations.
Web services elements:
<m:GetCurrentNews>
<m:NewsCat>Stock Market</m:NewsCat>
</m:GetCurrentNews>
</soap:Body>
</soap:Envelope>
A SOAP response:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.sample.com /2001/12/soap-envelope"
soap:encodingStyle="http://www.sample.com /2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.com/News">
<m: GetCurrentNewsResponse>
<m:News>Rates have gone down in the International stock Market etc.</m:News>
</m:GetCurrentNewsResponse>
</soap:Body>
</soap:Envelope>
3. UDDI
3.1 UDDI Definition
Universal Description Discovery and Integration specification provides a platformindependent way of describing services, discovering businesses, and integrating
business services using the Internet.
UDDI data structure provides a standardized way for listing the business services
available as well for providing a brief description about the same, together with the
access information.
4. WSDL
4.1 WSDL Definition
Load Runner can be used to create script for testing your Web Services. You can use
the VUGEN test generation wizard to automatically generate scripts, or create the
scripts manually. Both Desktop and Web application which involves Web Services can
be tested using Load Runner.
5.1 Manually creating script in Load Runner
Pre-requisite for manually creating the script.
1
WSDL files for the various Web Services used by the application.
List of the Web Services methods that are invoked for the scenario to be
scripted along with the input parameter and the connectivity between the
methods.
Note: We need the help of developers to find the set of web services invoked for a
particular scenario, their input and the connectivity between them.
When we have the WSDL files and the details of the methods invoked (which includes
the input parameter to be passed and the output parameters that has to be
captured) for a particular flow we can manually record the script by following the
below mentioned steps.
Step 1: Select Web Service Protocol and create and empty script
Click New Single Protocol Script and then select Web Service and click OK. This
creates and empty Web Service script.
Figure 1.1
Step 2: Import the necessary WSDL files
WSDL files can be imported by click on Manage Services. We can import as many
WSDL files as required.
WSDL files can be imported by using anyone of the options mentioned below
URL
File
UDDI
Quality Center
Figure 2.1
Figure 2.2
Figure 2.3
Step 3: Add the Service calls to the script in the required order
Click on Add Service. It shows the WSDL files that have been imported in the
Service drop down box and the operation supported by each of the WSDL file in the
Operation drop down box.
Now to add service call, first select the desired Service and then the Operation.
Input and output arguments corresponding to the operation selected are listed
below. In order to provide the input data select the required input variable and
provide the data in the Value box.
If you need to save any of the output parameter (i.e. correlate any value), select the
respective variable, check Save return value in parameter and provide the
parameter name. This way you can correlate as many values as required.
After providing the necessary input variables and capturing the required output
parameters, Click OK. A script gets generated to invoke service call with the input
data provided and it also takes care of the correlation (i.e. capturing the output
data).
Figure 3.1
Figure 3.2
Figure 3.3
Figure 3.4
Figure 3.5
Step 4: Repeat Step 3 to generate script for all the required service call.
5.2 Recording a Web Service script in Load Runner
Step 1: Select Web Service Protocol and create and empty script
Click New Single Protocol Script and then select Web Service and click OK. This
creates and empty Web Service script.
Figure 1.1
Step 2: Specify application to record.
You are provided with two options:
a. Record default Web Browser. It Records the actions of the default Web
browser, beginning with the specified URL. Select this option where you access the
Web Service through a Web-based UI.
b. Record any application. Records the actions of the client application. Specify or
browse for the path in the Program to record box. Specify any relevant arguments
and working directories.
Figure 2.1
Step 3: Make necessary changes to the configuration setting and click
Finish.
Application is invoked by the Vugen and it begins recording. We need to perform the
required action within the application and then click on the Stop button. The script
gets created automatically.
5.3 Enhancing the recorded script
5.3.1 Correlation:
Case 1: In order to capture a single value follow the below mentioned steps
a. Switch to Tree View.
b. Click on Server Response tab.
c. You can manual browse through server response of all the service call and
figure out where the value first appears. Else you can make use of Query
Builder and search for the value in each of service call individually.
d. Now right click on the value and select Save value in a parameter option.
Following piece of code gets added and this captures the required value
lr_xml_get_values("XML={response}",
"FastQuery=/Envelope/Body/UserDataResponse/UserDataResult/LoggedInUser/UserID",
"ValueParam=ParamValue_UserID",
LAST);
Case 2: In order to capture a multiple values follow the below mentioned steps
a. Switch to Tree View.
b. Click on Server Response tab.
c. You can manually browse through server response of all the service call and
figure out the set of values to be captured. In the below example
EmployeeID has to be captured. It appears in multiple node and all the
values has to be captured.
d. Now right click on the value and select Save value in a parameter option.
e. Provide parameter name and click OK.
f.
We can retrieve all these three value using a single query by making the following
changes to any one of the query above:
lr_xml_get_values("XML={response}",
"Query=/Envelope/Body/EmployeeDetailResponse/EmployeeDetailResult/diffgram/EmployeeDetailData/*/
EmployeeID",
"ValueParam=ParamValue_EmployeeID",
"SelectAll=yes",
LAST);
In the above code * can take any value. Hence all the values from the server
response is captured
Note: A fast query can be used when the exact path to the information is known.
Fast query accepts single slashes, nodes, and brackets. It is used to return a single
value, and can not be used with Multiple Query Matching.
Case 3: In order to capture a XML Fragment follow the below mentioned steps
a. Switch to Tree View.
b. Click on Server Response tab.
c. Manually browse through server response of find out the XML fragment to be
captured. In the below mentioned example we are required to capture the
entire EmployeeDetail.
Following piece of code gets added and this captures the required data
lr_xml_extract("XML={response}",
"FastQuery=/Envelope/Body/EmployeeDetailResponse/EmployeDetailResult/diffgram/EmployeeDetailData/
EmployeeDetail",
"XMLFragmentParam=ParamXml_EmployeeDetail",
LAST);
NOTE : Values within the SOAP body are the variables which has to be either
parameterized or correlated.
5.3.2 Verification Point:
Case 1: Using LR in-built function (lr_xml_find) for response validation
lr_xml_find serves the same purpose as web_reg_find in Web(HTTP/HTML)
protocol.
a. Switch to Tree View.
b. Click on Server Response tab.
c. Manually browse through server response of find out the XML fragment to be
captured. In the below mentioned example we are required to capture the
entire EmployeeDetail.
d. Now right click on the value and select Insert XML check option.
e. If required you can check Ignore case and Continue on error and then click
OK
Following piece of code gets added and this does the necessary validation.
lr_xml_find("XML={response}",
"FastQuery=/Envelope/Body/UserDataResponse/UserDataResult/LoggedInUser/UserID",
"Value=12345",
LAST);
Code generated when Ignore case and Continue on error check box are selected
lr_xml_find("XML={response}",
"FastQuery=/Envelope/Body/UserDataResponse/UserDataResult/LoggedInUser/UserID",
"Value=12345",
"IgnoreCase=yes",
"NotFound=continue",
LAST);
We need to place above code exactly below the Web Service request which has to be
validated. Here the value substituted for LoginID will be searched in response from the
server. We can also replace the {LoginID} with a hard coded value.
The following piece of code has to be placed at the end of the transaction.
/*****************************If match found transaction
PASSES**************************/
if(position_1!=NULL)
{
lr_end_transaction("GMS_A01_OpenGMSMain ", LR_PASS);
}
/*******************************Else the transaction
FAILS*******************************/
else
{
lr_end_transaction("GMS_A01_OpenGMSMain ", LR_FAIL);
}