51Testing软件测试论坛
标题:
帮忙看一下,loadrunner报错:Error -32999:
[打印本页]
作者:
bananawj
时间:
2011-9-29 17:17
标题:
帮忙看一下,loadrunner报错:Error -32999:
我的loadrunner脚本如下:
#include "web_api.h"
Action()
{
int httpcode;
char POSTURL[2000];
long length;
web_set_max_html_param_len("1024");
web_reg_save_param("resultCode",
"LB=result resultCode=\"",
"RB=\"",
"NotFound=ERROR",
LAST);
web_create_html_param("GETURL","<url>","</url>");
web_custom_request("web_custom_request",
"URL=http://10.137.35.244:35051/SOE/devapp/IUploadAndDownload",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Body=<?xml version='1.0' encoding='UTF-8'?><uploadFile> <accnt>353000001</accnt> <ctnLst length='1'> <upldContent> <name>bug21</name> <fileName>sano.jpg</fileName> <size>1</size> <desc>pretty</desc> <openType>1</openType> </upldContent> </ctnLst> <ctlgID>0</ctlgID></uploadFile></uploadFile>",
LAST);
if(strncmp(lr_eval_string ("{resultCode}"),"0",1) ==0)
lr_output_message("The action is success");
else
lr_error_message(lr_eval_string ("{resultCode}"));
lr_output_message(lr_eval_string("{GETURL}"));
length = strlen(lr_eval_string("{GETURL}"));
lr_output_message("length=%d", length);
strncpy(POSTURL,lr_eval_string("{GETURL}"),length);
lr_output_message("the string is %s",POSTURL);
web_custom_request("web_custom_request",
"URL=POSTURL",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Body=a",
LAST);
return 0;
}
执行结果报错:Action1.c(3): Error -32999: Invalid scheme (not "http:" / "https:") in URL="
OSTURL" [MsgId: MERR-32999]
Action1.c(3): Warning -32993: Internal Error (call customer services): A non-valid LrwiUrlCrack (_bIsValid==false) is being copy-constructed in LrwiUrlCrack:
rwiUrlCrack (copy CTOR) [MsgId: MWAR-32993]
Action1.c(3): web_custom_request("web_custom_request") highest severity level was "ERROR", 0 body bytes, 0 header bytes [MsgId: MMSG-26388]
但是lr_output_message("the string is %s",POSTURL);打印POSTURL是我需要的url值:
the string is
http://10.137.35.249:34281/SME/s ... 8043E59FF84FA6FF83C
Ending action Action.
请教高手,我的POSTURL是不是没有传入web_custom_request中,所以导致这个问题?
请帮帮忙!!!!!
作者:
tbqtbq
时间:
2011-9-29 22:26
可参考:
http://www.cnblogs.com/guanhe/archive/2006/09/04/494223.html
摘取内容如下:
web_custom_request方法的原型是:
int web_custom_request (const char *RequestName, <List of Attributes>,[EXTRARES, <List of Resource Attributes>,] LAST );
其中List of Attributes的主要项目是Method,URL和BODY等。对这个例子来说,我们可以很容易构造出我们需要的request的BODY内容。
……
strcpy(creq, "Body=1=on&flightID=");
strcat(creq, lr_eval_string("{fID1}"));
strcat(creq, "&2=on&flightID=");
strcat(creq, lr_eval_string("{fID2}"));
strcat(creq, "&.cgifields=1&.cgifields=2");
strcat(creq, "&removeFlights.x=116&removeFlights.y=8");
其中{fID1}、{fID2}等都是通过关联获得的flightID的数据。
因此,我们可以根据图中的数据编写custom_request语句:
web_custom_request("itinerary.pl",
"Method=POST",
"URL=http://localhost/MercuryWebTours/itinerary.pl",
"RecContentType=text/xml",
creq,
"Snapshot=t4.inf",
LAST);
较为完整的代码如下: Action()
{
char creq[500];
web_reg_save_param("fID1", "LB=INPUT TYPE=\"hidden\" NAME=\"flightID\" VALUE=\"", "RB=\"", "ORD=1",
"SEARCH=BODY", LAST);
web_reg_save_param("fID2", "LB=INPUT TYPE=\"hidden\" NAME=\"flightID\" VALUE=\"", "RB=\"", "ORD=2",
"SEARCH=BODY", LAST);
web_url("welcome.pl",
"URL=http://localhost/MercuryWebTours/welcome.pl?page=itinerary",
"Resource=0",
"RecContentType=text/html",
"Referer=http://localhost/MercuryWebTours/nav.pl?page=menu&in=home",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"URL=images/in_itinerary.gif", "Referer=http://localhost/MercuryWebTours/nav.pl?page=menu&in=itinerary", ENDITEM,
"URL=images/home.gif", "Referer=http://localhost/MercuryWebTours/nav.pl?page=menu&in=itinerary", ENDITEM,
LAST);
lr_think_time(2);
strcpy(creq, "Body=1=on&flightID=");
strcat(creq, lr_eval_string("{fID1}"));
strcat(creq, "&2=on&flightID=");
strcat(creq, lr_eval_string("{fID2}"));
strcat(creq, "&.cgifields=1&.cgifields=2");
strcat(creq, "&removeFlights.x=116&removeFlights.y=8");
lr_output_message(creq);
web_custom_request("itinerary.pl",
"Method=POST",
"URL=http://localhost/MercuryWebTours/itinerary.pl",
"RecContentType=text/xml",
creq,
"Snapshot=t4.inf",
LAST);
return 0;
}
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2