|
本帖最后由 MYMREMIND 于 2010-10-27 08:52 编辑
大家好,我在用socket协议写了个脚本后,回放没有错误,执行场景的时候,如果不加持续时间也没有错误,但是一加入持续时间,执行场景的时候就会报错:save param 参数无效。错误代码: 9005
求解决,谢谢!
详细脚本:
Init:
#include "lrs.h"
vuser_init()
{
char m[100];
char n[50];
char a[50];
lr_load_dll("msado15.dll");
lr_load_dll("SQLConnector.dll");//调用数据库操作DLL
memcpy(m, lr_eval_string("<NewParam>"),strlen(lr_eval_string("<NewParam>")));
memcpy(n, lr_eval_string("<NewParam_1>"),strlen(lr_eval_string("<NewParam_1>")));
strcat(m,n);
memcpy(a, lr_eval_string("<NewParam_2>"),strlen(lr_eval_string("<NewParam_2>")));
strcat(m,a);
//从两个数据库中分别提取数据然后组合成一个字符串
lr_save_string(m,"inputstr");//将m的值保存到参数inputstr
lr_output_message("inputstr=%s",lr_eval_string("<inputstr>"));
lrs_startup(257);
return 0;
}
Action:
include "lrs.h"
Action()
{
char cmd_str[100];
char outputmsg[100];
struct {
char f1c[100];
int f1i;
long f1l;
char f2c[100];
int f2i;
long f2l;
char f3c[100];
int f3i;
long f3l;
}insertfiled;
lrs_save_param_ex("socket0","user",lr_eval_string("<inputstr>"), 0, strlen(lr_eval_string("<inputstr>")),NULL, "NewParam1");
//将要发送到server端的数据从init部分传递过来并保存到参数NewParam1
lrs_create_socket("socket0","TCP","RemoteHost=10.120.33.5:3343",LrsLastArg);
lr_rendezvous("sendmessage");
lr_start_transaction("sendmessage");
lrs_send("socket0","buf0",LrsLastArg);//发送
lrs_receive("socket0","buf1",LrsLastArg);//接收
lr_end_transaction("sendmessage", LR_AUTO);
//接收服务器返回消息
lrs_save_param("socket0",NULL,"Param_Return",0,2);
lr_output_message("Param_Return=%s",lr_eval_string("<Param_Return>"));
//读取buf1中接收到的数据
lrs_save_param("socket0","buf1","Param_Buffer",0,30);
lr_output_message("Param_Buffer=%s",lr_eval_string("<Param_Buffer>"));
memset(outputmsg,0,sizeof(outputmsg));
memcpy(outputmsg,lr_eval_string("<Param_Return>"),strlen(lr_eval_string("<Param_Return>")));
memset(cmd_str,0,sizeof(cmd_str));
strcpy(cmd_str,"insert into test3 values(");//将服务器端返回的数据插入到数据库
sprintf(insertfiled.f1c,"%s",lr_eval_string("<Param_Buffer>"));
sprintf(insertfiled.f2c,"%s","Getdate()");
sprintf(insertfiled.f3c,"%s",lr_eval_string("<Param_Return>"));
strcat(cmd_str,"'");
strcat(cmd_str,insertfiled.f1c);
strcat(cmd_str,"',");
strcat(cmd_str,insertfiled.f2c);
strcat(cmd_str,",'");
strcat(cmd_str,insertfiled.f3c);
strcat(cmd_str,"')");
Insert(cmd_str);
if(strncmp(insertfiled.f3c,"00",2)!=0) //如果返回码不等于00,输出错误提示
{lr_error_message(outputmsg);}
lr_think_time(1);
return 0;
}
End:
include "lrs.h"
vuser_end()
{
lrs_cleanup();
return 0;
}
Date.WS
;WSRData 2 1
send buf0 30
"<NewParam1>"
recv buf1 30
-1 |
|