天天看點

Web Services performance using LoadRunner HTTP Vuser script

通過使用LR的HTTP協定測試Web Services的性能【譯文】

URL: http://blog.testsautomation.com/ ... e-using-loadrunner/  

譯者:Rita      原作者:Waldemar   

  一個小例子說明如何使用LR API測試Web Service的性能。

  讓我們說一下基于HTTP的Web Service使用SOAP協定。我們想測試發送請求和接收響應的速度有多快,因為我們的服務使用HTTP協定,我們可以使用簡單HTTP協定的腳本去測試。

Action()

{

web_reg_save_param("Response","LB=", "RB=", LAST); //用關聯函數取得響應時間_rita注

web_add_header("SOAPAction", "SampleMethod");

lr_start_transaction("REQ");

web_custom_request("Sample_Request","Method=POST",

       "Mode=HTML",

         "RecContentType=text/xml",

         "EncType=text/xml; charset=utf-8",

         "URL=http://example.com:1234/sample/",

         "Body=<Envelope xmlns=/"http://example.com/sample/">/n"

               "   <Header/>/n"

               "   <Body>/n"

               "   <price><id>001</id></price>/n"

               "   </Body>/n"

               "</Envelope>",

   "LAST");

   lr_end_transaction("REQ", LR_AUTO);

   lr_output_message("Response is : %s/n", lr_eval_string("{Response}")); //輸出響應時間值

   return 0;

}