使用LR11对webservice协议的接口测试应用
脚本开发步骤:
1、打开vuser generator,新建一个脚本,选择webservice协议;
2、选择Manage Services(服务管理),打开webservice服务管理页面;
3、然后选择Import Service,输入服务的url地址导入,然后按Import和OK按钮即可;
4、选择Add Service Call(服务调用)选择服务下的使用的方法名,然后填入参数值,直接OK,自动生成原始脚本框架;
5、导入格式化后的xml报文,对脚本做二次强化开发;可以使用import soap功能对xml格式化后直接贴到脚本中即可;
脚本样例:
Action() { int rNum;
rNum = rand() % 30+3;
lr_save_datetime("%Y-%m-%d",DATE_NOW + (ONE_DAY*rNum),"departdate");
lr_save_datetime("%Y-%m-%d",DATE_NOW + (ONE_DAY*rNum)+ONE_DAY*3,"nextday");
lr_start_transaction("Project_single_startWF");
web_service_call( "StepName=Request_101",
"SOAPMethod=SearchService|SearchServiceSoap|Request",
"ResponseParam=response",
"Service=SearchService",
"ExpectedResponse=SoapResult",
"Snapshot=t1384155703.inf",
BEGIN_ARGUMENTS,
"requestXML="
"<Request>"
XXXX(请求的报文)
"</Request>",
END_ARGUMENTS, BEGIN_RESULT, END_RESULT, LAST);
lr_save_searched_string(lr_eval_string("{response}"),500,0,"ResultCode",2,7,"Save_Str_here");
if(strcmp("Success", lr_eval_string("{Save_Str_here}")) == 0)
{ lr_end_transaction("Project_single_startWF", LR_AUTO); }
else { lr_end_transaction("Project_single_startWF", LR_FAIL);
lr_error_message("result = %s", lr_eval_string("{response}")); }