51Testing软件测试论坛

标题: loadrunner12 socket问题 [打印本页]

作者: mlvex123    时间: 2015-3-3 08:45
标题: loadrunner12 socket问题
脚本如下:action部分如下:

#include "lrs.h"

Action()
{
        char *ReceivedBuffer;
       
    lrs_startup(257);       
    lrs_create_socket("socket1", "TCP", "RemoteHost=某个IP:80",  LrsLastArg);
       
    lrs_send("socket1", "buf0", LrsLastArg);
    lrs_receive("socket1", "buf1", LrsLastArg);
       
        //输出buf1的内容
    ReceivedBuffer=lrs_get_received_buffer("socket1",0,-1,NULL);
    lrs_save_param_ex("socket1","user",ReceivedBuffer,0,600,"ascii","param");
    lr_output_message("the content of received buffer2 is %s",lr_eval_string("{param}"));   
    //得到其中sessionID并保存到变量NewParam同时打印出来
    lrs_save_searched_string("socket1",NULL,"NewParam","LB=Set-Cookie: JSESSIONID=","RB=; Path",1,0,-1);
    lr_output_message("Param = %s",lr_eval_string("{NewParam}"));

    lrs_send("socket1", "buf2", LrsLastArg);
    lrs_receive("socket1", "buf3", LrsLastArg);

    lrs_disable_socket("socket1", DISABLE_SEND);
    lrs_close_socket("socket1");
    return 0;
}

data.ws如下:
;WSRData 2 1

send  buf0 378
    "GET /xxzjy/ HTTP/1.1\r\n"
    "Accept: */*\r\n"
    "Accept-Language: zh-Hans-CN,zh-Hans;q=0.5\r\n"
    "User-Agent: Mozilla/4.0 (compatible; MSIE 9.0; qdesk 2.5.1278.201; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; QQBrowser/8.0.3345.400)\r\n"
    "Accept-Encoding: gzip, deflate\r\n"
    "Host: IP地址\r\n"
    "Connection: Keep-Alive\r\n"
    "\r\n"

recv  buf1 1
    "2"

send  buf2 698
    "GET /xxzjy/jdy/zlgl/index.jsp HTTP/1.1\r\n"
    "Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n"
    "Referer: http://IP地址/xxzjy/\r\n"
    "Accept-Language: zh-Hans-CN,zh-Hans;q=0.5\r\n"
    "User-Agent: Mozilla/4.0 (compatible; MSIE 9.0; qdesk 2.5.1278.201; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; QQBrowser/8.0.3345.400)\r\n"
    "Accept-Encoding: gzip, deflate\r\n"
    "Host: 10.10.10.15\r\n"
    "Connection: Keep-Alive\r\n"
    "Cache-Control: no-cache\r\n"
    "Cookie: JSESSIONID={NewParam}\r\n"
        "\r\n"

recv  buf3 1
    "2"

-1

我的想法是通过 lrs_receive("socket1", "buf1", LrsLastArg);获取其中的sessionid,然后给lrs_send("socket1", "buf2", LrsLastArg);中使用。
为什么最后lrs_receive("socket1", "buf3", LrsLastArg);总是提示302 Moved Temporarily 并指向一个session超时的页面?
注: loadrunner12,参数化是使用{},而不是<> ??,点右键参数化,自动变为{}








欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2