关于web_custom_request函数的一些问题(望指点)
我在录制HTTP/WEB脚本回放的时候,有一段脚本代码/*这些表示提交发表的问题~*/
/*下面是发表内容为test,标题为test1的疑问,账号是:F001*/
web_custom_request("StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx",
"URL=http://192.168.11.2:88/lgsoft30/ajaxpro/StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=text/plain",
"Referer=http://192.168.11.2:88/lgsoft30/StudyPlan/Student/Tutor_Index.aspx?Plan_ID=H0000056",
"Snapshot=t103.inf",
"Mode=HTML",
"EncType=text/plain; charset=utf-8",
"Body={\"content\":\"<DIV>TEST1</DIV>\"}",
LAST);
web_reg_find("Search=Body",
"Text=1",
"NotFound=EMPTY",
LAST);
web_custom_request("StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx_2",
"URL=http://192.168.11.2:88/lgsoft30/ajaxpro/StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=text/plain",
"Referer=http://192.168.11.2:88/lgsoft30/StudyPlan/Student/Tutor_Index.aspx?Plan_ID=H0000056",
"Snapshot=t104.inf",
"Mode=HTML",
"EncType=text/plain; charset=utf-8",
"Body={\" Plan_ID\":\"H0000056\",\"UserID\":\"F001\",\"postTitle\":\"TEST\",\"
postContent\":\"<DIV>TEST1</DIV>\"}",
LAST);
/*发表成功~*/
录制时第一个web_custom_request函数,服务器返回的值:
Header:
------------------------------------------
HTTP/1.1 200 OK
Date: Mon, 24 May 2010 07:17:05 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: text/plain; charset=utf-8
Content-Length: 1519
Body:
------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type c></HEAD>
<BODY><pRE>"TEST1";/*</PRE></BODY></HTML>
录制时第二个web_custom_request函数,服务器返回的值:
Header:
------------------------------------------
HTTP/1.1 200 OK
Date: Mon, 24 May 2010 07:17:05 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: text/plain; charset=utf-8
Content-Length: 6
Body:
------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type c></HEAD>
<BODY><pRE>"1";/*</PRE></BODY></HTML>
我的分析是,第一个请求是验证提交的数据是否合理,然后第二个是提交数据给服务器,
成功则服务器返回1.
在执行回放的时候,日志服务器返回的日志则是
Action.c(339): 警告: 带有参数分隔符的字符串“"content":"<DIV>TEST1yguggyuygu</DIV>"”不是参数。
Action.c(339): “http://192.168.11.2:88/lgsoft30/ajaxpro/StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx”(RelFrameId=1)的 t=162304ms: 178 个字节响应标头
Action.c(339): HTTP/1.1 200 OK\r\n
Action.c(339): Date: Mon, 24 May 2010 12:56:51 GMT\r\n
Action.c(339): Server: Microsoft-IIS/6.0\r\n
Action.c(339): X-Powered-By: ASP.NET\r\n
Action.c(339): X-AspNet-Version: 2.0.50727\r\n
Action.c(339): Cache-Control: private\r\n
Action.c(339): Content-Length: 0\r\n
Action.c(339): \r\n
Action.c(339): web_custom_request("StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx") 已成功,0 个正文字节,178 介标头字节
Action.c(358): 警告: 带有参数分隔符的字符串“"plan_ID":"H0000056","UserID":"F001","2","postTitle":"TEST","postContent":"<DIV>TEST1yguggyuygu</DIV>"”不是参数。
Action.c(358): “http://192.168.11.2:88/lgsoft30/ajaxpro/StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx”(RelFrameId=1)的 t=162502ms: 178 个字节响应标头
Action.c(358): HTTP/1.1 200 OK\r\n
Action.c(358): Date: Mon, 24 May 2010 12:56:52 GMT\r\n
Action.c(358): Server: Microsoft-IIS/6.0\r\n
Action.c(358): X-Powered-By: ASP.NET\r\n
Action.c(358): X-AspNet-Version: 2.0.50727\r\n
Action.c(358): Cache-Control: private\r\n
Action.c(358): Content-Length: 0\r\n
Action.c(358): \r\n
Action.c(358): web_custom_request("StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx_2") 已成功,0 个正文字节,178 介标头字节
在这俩个函数里没有需要关联的地方,Plan_ID=H0000056是正确的,不需要关联,为什么俩个web_custom_request的正文里没有返回数据并且没有提交成功呢?在运行查看器里会观察到错误的页面,本人知识有限,不知道怎么解决,望高手指点一二!:)
[ 本帖最后由 wangchao6656 于 2010-5-24 21:22 编辑 ] 顶起等待高手答复~ 339行 是哪个? 多关注一下发出去是什么马上就知道答案了
录制出现 web_custom_request有错误很常见
回复 3# 的帖子
339是第一个web_custom_request的日志,发送的内容主要是 "Body={\"content\":\"<DIV>TEST1</DIV>\"}",是不是参数在web_custom_request传的不对啊~[ 本帖最后由 wangchao6656 于 2010-5-25 11:51 编辑 ] 开发前台的代码是:var RetVa= StudyPlan_Student_Tutor_Index.NewPost(Plan_ID,UserID,2, postTitle,postContent).value;通过传入参数到后台定义的NewPost函数去提交内容,正确返回1到var RetVa中~ NewPost在后台的定义如下:
AjaxPro.Utility.RegisterTypeForAjax
//以上俩行能声明该函数能被前台调用
public static string NewPost(string Plan_ID, string UserID, int UserType, string PostTitle, string PostContent)
{
lgzx_SSPQuestion_BLL SSPQuestion_BLL=new lgzx_SSPQuestion_BLL();
SSP_Function AFunction = new SSP_Function();
string NewPostContent = AFunction.insertPic(PostContent);
int Retint = SSPQuestion_BLL.Add_SSPQuestion_BLL(Plan_ID, UserID, UserType, PostTitle, NewPostContent);
return Convert.ToString(Retint);
}
SSPQuestion_BLL.Add_SSPQuestion_BLL为自定义的后台存储提交内容的函数~ 把
<DIV>TEST1</DIV>
换成
%3cDIV%3eTEST1%3c%2fDIV%3e
试试
你要抓的是HTTP协议从本机到服务器的内容是什么,其他没什么看的
回复 7# 的帖子
以下是我用Sniffer抓包工具获取到的与服务器HTTP通讯的过程,只看加粗部分就可以知道他的内容了POST /lgsoft30/ajaxpro/StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx HTTP/1.1
Accept: */*
Accept-Language: zh-cn
x-ajaxpro-method: getContent
Referer: http://192.168.11.2:88/lgsoft30/ ... x?Plan_ID=H0000056#
Content-Type: text/plain; charset=utf-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Host: 192.168.11.2:88
Content-Length: 29
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: UserID=F001; ASP.NET_SessionId=kqaby345xv5nqv55tvgyik45
{"content":"<DIV>test</DIV>"}HTTP/1.1 200 OK(发送给服务器的body部分)
Date: Tue, 25 May 2010 06:28:08 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: text/plain; charset=utf-8
Content-Length: 9
//服务器返回的值
"test";/*POST /lgsoft30/ajaxpro/StudyPlan_Student_Tutor_Index,App_Web_tutor_index.aspx.fdeda029.ashx HTTP/1.1
Accept: */*
Accept-Language: zh-cn
x-ajaxpro-method: NewPost
Referer: http://192.168.11.2:88/lgsoft30/ ... x?Plan_ID=H0000056#
Content-Type: text/plain; charset=utf-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Host: 192.168.11.2:88
Content-Length: 89
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: UserID=F001; ASP.NET_SessionId=kqaby345xv5nqv55tvgyik45
//在发送给服务器的Body部分
{"Plan_ID":"H0000056","UserID":"F001","PostTitle":"test","PostContent":"<DIV>test</DIV>"}HTTP/1.1 200 OK
Date: Tue, 25 May 2010 06:28:08 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: text/plain; charset=utf-8
Content-Length: 6
//服务器返回1表示提交成功~
"1";/*GET /lgsoft30/StudyPlan/Student/Student_Tutorship_right.aspx?CoursePlan_ID=CP20100524144141 HTTP/1.1
Accept: */*
Referer: http://192.168.11.2:88/lgsoft30/ ... an_StudentTree.aspx
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Host: 192.168.11.2:88
Connection: Keep-Alive
Cookie: UserID=F001; ASP.NET_SessionId=kqaby345xv5nqv55tvgyik45
[ 本帖最后由 wangchao6656 于 2010-5-25 16:36 编辑 ] 简单来说由于你返回的数据包是用{}来做的,而这个内容又正好是参数化的标志,所以会脚本回放出错,你修改一下参数化边界的格式就行了
别的问题没看,只看了脚本回放的错误
回复 9# 的帖子
恩,这个问题是重点~~~发出去的BODY脚本认为是参数了,没当字符串
回复 9# 的帖子
修改了参数化的格式也不行,服务器还是返回空值~ 我录制中用到的web_custom_request函数,为什么它提交数据给服务器的时候,服务器总是返回空值。正常来说是不会返回空值的。 是不是web_custom_request函数要怎么设置才能正常返回值呢?我录制的脚本中,很多地方回放的时候都没有返回值,检查了一下,不是关联的问题~ 对比一下你自己手动操作和脚本发出去的整个HTTP请求有什么区别吧回复 14# 的帖子
脚本发出去的HTTP请求能看到,手动发出去的HTTP请求该怎么看呢?回复 15# 的帖子
推荐 fiddler2 ,本地代理式软件,HTTP专用简单易用,而且很清晰
回复 16# 的帖子
好,我试试,如果解决了这个问题,我再告诉你~多谢了~ 楼主这个问题解决没啊,我的也是返回的为空值呢,提交了参数但是实际上参数都没插入数据库 楼主解决问题了吗
页:
[1]