Web Services Protocol in Loadrunner with Examples

What is Web Service?

Well, it is someone service that you want to use through web/online. It might be your company internal service, outside services like weather.com Service, Google maps service etc.

Many organization are dividing the huge application to micro services. Which helps the application developers to quickly upgrade the service and push the change to the production.

Following are the detail steps that you need to follow in order to test the micro services.

Types of Services:

We have mainly four types of Web Services XML-RPC, UDDI, SOAP and REST. See the details explanation in this link which is very helpful

Example 1:

Your company will have different branches like Online Order, Delivery and Pickup.

While doing online order you want to use Delivery service, so you are indirectly using Delivery service.

Delivery Service team gives you details about their service and you call that service every time you want Delivery.

  1. Is delivery team did the performance test for that service,
  2. How many concurrent calls it supports? What is the response time SLA for that service?
  3. Which protocol works Best for Web Services Load test?

Before handing over to other people Delivery Service team has to do performance test and see how fast their service responds and how many concurrent calls it supports.

The Performance Test Goal of any web service is Concurrent Calls and Response time.

Example 2

You want to use Weather Service in your application to display current weather in your location. Usually these services are charged based on number of calls you are making in a day.

Before Handing over the weather service the Weather Service Company will do performance test with huge concurrent calls and concludes that my Weather service supports 10000 concurrent calls per second and it responds within 0.5 seconds.

Performance testing Goals for Web Service

What Questions do you ask to Developer, Project Manager or Business Analyst Before Starting Performance Test?

Answer: How many concurrent calls this service has to support in production?

Developer Answer Example: My service should load in 0.5 sec with 100 concurrent calls.

So How many concurrent users that you need to use?

Answer: It depends on the service responding, you need to adjust your concurrent users in such a way that you meet your 100 concurrent calls.

Web Service Scripting

There are two different ways that you can do scripting in Loadrunner, one is using Web Service Protocol and the other is Web Protocol.

If it is a simple get request you can using web protocol.

If it is a WSDL file the best way to do is using Web Service Protocol

Scripting Using Web Service Protocol with SOAP WSDL File

I am taking the following URL as an example WSDL File, the response you get is saying Hello Your Name.

Example: http://www.learnwebservices.com/services/hello?WSDL

How to do the scripting using WSDL File in Web Service Protocol

Open VuGen and Select Web Service Protocol

Click on SOA Tools on Top bar and Select Manage Services

Click on Import and give the WSDL URL – http://www.learnwebservices.com/services/hello?WSDL

Click on Apply and Okay.

Go to SOA Tools Again and click on Add Service Call – Expand Hello Request and Give your name.

And run the script you will see in the response saying Hello Vijay.

Sample Script

Action()
{
    
    web_service_call( "StepName=
SayHello_101",
        "SOAPMethod=
HelloEndpointService|HelloEndpointPort|SayHello",
        "ResponseParam=
response",
        "Service=
HelloEndpointService",
        "ExpectedResponse=
SoapResult",
        "Snapshot=
t1579581442.inf",
        
BEGIN_ARGUMENTS,
        "xml:HelloRequest="
            "<HelloRequest>"
                "<Name>Vijay</Name>"
            "</HelloRequest>",
        
END_ARGUMENTS,
        
BEGIN_RESULT,
        
END_RESULT,
        
LAST);


    
    lr_xml_find("Xml=
{SayHello_101_Response}",
            "Value=
Hello Vijay!",
            "Query=
/SayHello/HelloResponse/Message/text()",
               
LAST);
    
    lr_xml_find("Xml=
{response}",
            "Value=
Hello Vijay!",
            "Query=/soap:Envelope[1]/soap:Body[1]/*[local-name()='SayHelloResponse'][1]/*[local-name()='HelloResponse'][1]/*[local-name()=
'Message'][1]/text()[1]",
               
LAST);
    
    lr_xml_get_values("XML=
{SayHello_101_Response}",
          "ValueParam=
MyName",
          "Query=
/SayHello/HelloResponse/Message/text()",
          
LAST );
    
    lr_output_message(lr_eval_string("Print my Name =
 {MyName}"));
    
    return 0;
}

How do you do Text Check in Web Services or Capture Values

You will use lr_xml_find function or lr_xml_get_values function to do validate the response and capture the values.

Correlation in Web Service Protocol

To correlate any values in xml you need to use lr_xml_get_values

Scripting Using Web Protocol Web

You can use the web protocol the following way and you can use web_reg_save_param function to correlate the values.

web_set_sockets_option(“SSL_VERSION”, “TLS1.2”);

    web_add_auto_header(“Sec-Fetch-Mode”, 
        “navigate”);

    web_add_header(“Sec-Fetch-User”, 
        “?1”);

    web_add_header(“Upgrade-Insecure-Requests”, 
        “1”);

    web_url("users", 
        "URL=https://gorest.co.in/public-api/users?_format=json&access-token=
DHn67whALOdexdsYeMhP93kyp71lSFs7NREp", 
        "Resource=
0", 
        "RecContentType=
application/json", 
        "Referer=", 
        "Snapshot=
t7.inf", 
        "Mode=
HTML", 
        
LAST);

You can also read our additional Loadrunner Tutorial

Leave a Comment