今天因为要做接口的性能测试,所以录制了个web service的脚本。过程中有些教训,值得记录一下。
录制完脚本,像往常一样,给脚本增加了手动关联的函数去获取接口的返回值,并没有用web service自带的去获取返回值。脚本如下:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
web_reg_save_param("returnCode",
"LB=HTTP\/1.1",
"RB=OK",
"Ord=1",
"NotFound=ERROR",
LAST);
web_service_call( "StepName=getDownloadKey_102",
"SOAPMethod=MusicPaymentService.MusicPayment.getDownloadKey",
"ResponseParam=response",
"WSDL=http://192.168.104.51:28080/jboss-net/services/MusicPayment?wsdl",
"UseWSDLCopy=1",
"Snapshot=t1259034940.inf",
BEGIN_ARGUMENTS,
"xml:event=<event><DID>00000</DID><DIDPwd>222222"
"333333</DIDPwd><MSISDN>{MSISDN}</MSISDN><NAS_GGSN_ID>10.10.10."
"10</NAS_GGSN_ID><accessPlatformID>"
"0021010</accessPlatformID><contentID>"
"123456789012345678</contentID><copyRightID>123456789012</copyRightID><feeKind>"
"03</feeKind><oprSrc>2</oprSrc><oprType>0</oprType>"
"<recieverNumber>{recieverNumber}"
"</recieverNumber><role>000</role><roleCode>000</roleCode><size>1024</size>"
"<subscriptionKind>002</subscriptionKind><terminalID>0001</terminalID><validCode>"
"</validCode></event>",
END_ARGUMENTS,
BEGIN_RESULT,
END_RESULT,
LAST);
lr_log_message("returnCode is : %s",lr_eval_string ("{returnCode}"));
回放的时候就出问题了,总是报“Warning: The string 'returnCode' with parameter delimiters is not a parameter.”的错误,日志输出也是“returnCode is :{returnCode}”。
开始的时候我以为输出日志的函数出了问题,检查了几遍脚本也没发现什么错误。后来才想起来这个warning是参数获取不成功的提示(一天不用手生啊.....)。于是用web service本身的设置去获取returnCode,如图:
![](https://pic002.cnblogs.com/img/erichhuang/200911/2009112617143914.jpg)
这下再运行脚本,果然,没有获取到参数。于是再修改下设置,如上啊开图一般,把整个返回的信息作为参数输出,结果很明了了,LR获取的接口返回信息,因为downURL里的特殊字符而没有获取完全,LR获取到的返回信息里根本就没有returnCode........
有了这次的教训,以后对于web Service,还是用他自带的获取参数的方式全部获取出来看看......不然白白浪费时间......
小贴士:只有切换到树状图脚本时,在树节点上点击右键,选择属性,才能打开脚本属性的设置页面![](https://pic002.cnblogs.com/img/erichhuang/200911/2009113016162026.jpg)