51Testing软件测试论坛
标题:
如何随机获取服务器响应数组值并保存成参数?
[打印本页]
作者:
xiaomeng
时间:
2007-11-22 10:57
标题:
如何随机获取服务器响应数组值并保存成参数?
lr_xml_get_values函数可以取到ExamID_ALL数组。请问如何随机获取其中之一,并保存到{ExamID}中供下次web service call调用?
web_service_call(...);
NumOfValues = lr_xml_get_values("XML={response}",
"Query=/Envelope/Body/SearchResponse/ResultSet/*/value[16]",
"ValueParam=ExamID_ALL",
"SelectAll=yes", LAST);
srand( time(NULL) );
i = rand() % (NumOfValues + 1);
sprintf( E_examid, "Retrieved value %d : {ExamID_ALL_%d}", i + 1, i + 1 );
lr_output_message(lr_eval_string(E_examid));
lr_output_message(lr_eval_string("firstExamID = {ExamID_ALL_1}"));
soap_request("..., "SOAPEnvelope=..."
"<requestedProcedureID xmlns=\"\">{ExamID}</requestedProcedureID>"
"Snapshot=t21.inf", "ResponseParam=response",
LAST);
作者:
leey
时间:
2007-11-22 13:35
看得晕,我猜是不是应该用
lr_save_string(ExamID, ExamID_ALL [ i ] );
[
本帖最后由 leey 于 2007-11-22 13:36 编辑
]
作者:
xiaomeng
时间:
2007-11-22 14:26
标题:
搞定了,共享下:)
int i = 0, NumOfValues = 0;
char E_examid[64];
NumOfValues = lr_xml_get_values("XML={response}",
"Query=/Envelope/Body/SearchResponse/ResultSet/*/value[16]",
"ValueParam=ExamID",
"SelectAll=yes", LAST);
srand( time(NULL) );
i = rand() % NumOfValues + 1;
sprintf(E_examid, "{ExamID_%d}", i);
sprintf(E_reportid, "{ReportID_%d}", i);
lr_save_string(lr_eval_string(E_examid), "ExamID");
lr_output_message(lr_eval_string("{ExamID}"));
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2