How to change input soap request as per test data in loadrunner?

♀尐吖头ヾ 提交于 2019-12-08 12:03:20

问题


I am working with one soap request where we need to pass,single data in one parameter and in 2nd iteration we need to pass multiple test data in same input request.Please help me how to change input soap request as per test data,please find below soap requests for single and multiple requests.

Single Request:

<ReqDtls>
<vReqs>
  <amount>1.00</amount>
  <cardNo>8897654778999</cardNo>
</Reqs>
<cardType>caredit</cardType>
</ReqDtls>

Multiple Requests:In same soap input requests,it is changing dynamically from POS system but i want to perform in loadrunner.

<ReqDtls>
<vReqs>
  <amount>1.00</amount>
  <cardNo>8897654778999</cardNo>
</Reqs>
<vReqs>
  <amount>2.00</amount>
  <cardNo>890897654778999</cardNo>
</Reqs>
<cardType>caredit</cardType>
</ReqDtls>

Any code in vugen to pass this type of values from excel file for loadtesting,please help how to do this one


回答1:


This is where you will use your foundation skills in programming as well as a web_custom_request() (Potentially) to send your own custom string.

Notice the repeated piece here

<vReqs>
  <amount>{amount_variable}</amount>
  <cardNo>{card_variable}</cardNo>
</Reqs>

You have a defined header

<ReqDtls>

And a defined footer

<cardType>caredit</cardType>
</ReqDtls>

This now becomes a matter of string concatenation in C and turning the variables into literals. Consider a loop and lowly sprintf() for this task. Note, variable declarations are not included in the code fragment

sprintf(mybigstring,"<ReqDtls>\r");
for (myloopcounter=1;myloopcounter<=mylooplimit;myloopcounter++)
{
     sprintf(mybigstring,
          "%s%s",
          mybigstring,
          lr_eval_string("<vReqs>\r<amount>{amount_variable}</amount>\r<cardNo>{card_variable}</cardNo>\r</Reqs>\r") );
     lr_advance_param("amount_variable");
     lr_advance_param("card_variable");
}
sprintf(mybigstring,"%s%s",mybigstring,"<cardType>caredit</cardType>\r</ReqDtls>");

The above is directly from noggin to screen so it may require a bit if fiddling, but it should give you an idea for a path.

Once you have your string, then you can use it in whatever request as needed.



来源:https://stackoverflow.com/questions/41607259/how-to-change-input-soap-request-as-per-test-data-in-loadrunner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!