51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2136|回复: 0
打印 上一主题 下一主题

[求助] loadrunner12 socket问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2015-3-3 08:45:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
脚本如下: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,参数化是使用{},而不是<> ??,点右键参数化,自动变为{}



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-17 07:00 , Processed in 0.062584 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表