LoadRunner在Web Services请求的XML格式串中需要参数化某一个参数,以前的做法是使用string类函数拼出新的XML串,但经过深入的学习lr_save_string()和lr_eval_string()两个函数,发现有更简洁的方法,如下:
使用函数lr_save_string()与lr_eval_string()完成转换:
lr_save_string( lr_eval_string("{NewParam}"),"username"); |
其中{NewParam}为使用lr自带的参数化而成的参数。
然后,传入username:
例如:
soap_request("StepName=Login", "URL=http://10.0.16.221/i6P/i6Service/WinLoginService.asmx", "SOAPEnvelope=<?xml version=/"1.0/" encoding=/"GBK/" standalone=/"no/"?" "><soap:Envelope xmlns:xsd=/"http://www.w3.org/2001/XMLSchema/" xmlns" ":xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xmlns:soap=/"http:/" "/schemas.xmlsoap.org/soap/envelope//"><soap:Body><Login xmlns=/"http:/" "/tempuri.org//"><userConnectString>lers14t;5a8i2ix3b4g7=318p=" "j0t030c2jyio1r9i0nid3tt4xp89ocaNv8yt0ycahce0ol9nwen4ieh0cxoth5t8vylepx" "lecp=jesI8qgel20cttlm3iaee=bn19tcn;yrsmheyorm0v9qe51rxs=" "ja1bw0eu.2e0b5.301;s6r3.bd2qp22s136;opdeDa9wt51aembxxarjsweelb=" "r6nttgrS0s50920541ih;equdIs5mer2r62 e=itodjl=.0s5kaw4;" "rtp8Na0bs6wsgmwssoo6r5pd9i=kr1pq2gu3s24hj5ve6ykvxql6il=" "nandI62.ua7hc0kkvbeCnsmpv;lyy3ptgsseaxgryy18b8o8rt4v0e2y2wibrgoygleh9=" "dmehh9020t3u.i2jd2ixgtsu26a1yxxbpaa10000001000010010000001000000000000" "000000100000000110000010000110000100000000000000</userConnectString>" "<curAcc>0001</curAcc><logid>{username}</logid><passWord/></Login></soap" ":Body></soap:Envelope>", "Snapshot=t35.inf", "ResponseParam=response", LAST);
|