Absent Member.
Absent Member.
706 views

Testing .NET WebAPI from Visual Studio 2012 iDE and LoadRunner

Hi,

 

I want to Test the .Net Web API from Visual Stusio 2012 (C#)  and LoadRunner.

===========================================================================================

For Example - Using WebServices Protocol I have create the below mentioned webservice and it is working fine also..

 

web_service_call( "StepName=ConversionRate_101",

        "SOAPMethod=CurrencyConvertor|CurrencyConvertorSoap|ConversionRate",
        "ResponseParam=response",
        "Service=CurrencyConvertor",
        "ExpectedResponse=SoapResult",
        "Snapshot=t1435782622.inf",
        BEGIN_ARGUMENTS,
        "FromCurrency=ARS",
        "ToCurrency=DZD",
        END_ARGUMENTS,
        BEGIN_RESULT,
        "ConversionRateResult=Param_ConversionRateResult",
        END_RESULT,
        LAST);

    lr_output_message(lr_eval_string("{Param_ConversionRateResult}"));

====================================================================================

 

Now the Question is --> HOW can I,  Create the same logic in Visual Studio 2012 IDE using C# language and after creating that script, use it in LoadRunner 12.0

 

Thanks,

Sam

0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

Hi,

At first, you have to get wsdl file from your service. You can use one of following ways:

- Use the WCF Service Host to start a new instance of your service (ex: WcfSvcHost.exe /service:<pathToServiceDll> /config:<pathToConfigFile>), and then add ?wsdl to the service address to access the wsdl (http://localhost:1234/Service.svc?wsdl for instance).

- Use Web Services Discovery Tool to export wsdl file by command: disco [/out:<dir>] <URL>. In which, default out directory is current directory, <URL> is your service URL.

Then you can use import WSDL function in LR to add web service you want to test.

 

Regards,

Thien

0 Likes
Highlighted
Absent Member.
Absent Member.

Thanks Thein,

 

But this is WebAPI using JSON and it is not using any wsdl..

Could you please let me know, how to achieve the solution of my problem ?

Thanks,

Sam

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi Sam,

 

You can try using web_custom_service as this blog post.

0 Likes
Highlighted
Absent Member.
Absent Member.

Thanks Thein,

 

But, i think there is some confusion, I am able to achieve this using Http/Html protocol..

The Problem is ==> If i am using .NET virtual user type and open the VSTS 2012 IDE and want to Write a Code to POST this WebAPI, HOW i would be able to do that....

BECAUSE, in the VSTS 2012 IDE, the "web_custom_request" is not recognized... is there any way to POST the web services requests from the Visual Studio 2012 IDE.. any method exist ??

 

Please let me know..

 

Thanks,

Sam

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi Sam,

 

Not sure if you want me to help in coding? About POST request, you can try HttpClient. Here are some code samples.

 

Regards,

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.