51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 8935|回复: 18
打印 上一主题 下一主题

[原创] 关于web_custom_request函数的一些问题(望指点)

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2010-5-24 21:12:37 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
我在录制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 介标头字节          [MsgId: MMSG-26386]
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 介标头字节          [MsgId: MMSG-26386]


在这俩个函数里没有需要关联的地方,Plan_ID=H0000056是正确的,不需要关联,为什么俩个web_custom_request的正文里没有返回数据并且没有提交成功呢?在运行查看器里会观察到错误的页面,本人知识有限,不知道怎么解决,望高手指点一二!

[ 本帖最后由 wangchao6656 于 2010-5-24 21:22 编辑 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

  • TA的每日心情
    难过
    2015-11-8 20:48
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    19#
    发表于 2015-11-8 20:57:25 | 只看该作者
    楼主解决问题了吗
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    18#
    发表于 2014-11-27 17:23:24 | 只看该作者
    楼主这个问题解决没啊,我的也是返回的为空值呢,提交了参数但是实际上参数都没插入数据库
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    17#
     楼主| 发表于 2010-5-26 11:09:28 | 只看该作者

    回复 16# 的帖子

    好,我试试,如果解决了这个问题,我再告诉你~多谢了~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    16#
    发表于 2010-5-26 11:04:38 | 只看该作者

    回复 15# 的帖子

    推荐 fiddler2 ,本地代理式软件,HTTP专用
    简单易用,而且很清晰
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    15#
     楼主| 发表于 2010-5-26 10:44:48 | 只看该作者

    回复 14# 的帖子

    脚本发出去的HTTP请求能看到,手动发出去的HTTP请求该怎么看呢?
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    14#
    发表于 2010-5-26 10:12:03 | 只看该作者
    对比一下你自己手动操作和脚本发出去的整个HTTP请求有什么区别吧
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    13#
     楼主| 发表于 2010-5-26 09:33:05 | 只看该作者
    是不是web_custom_request函数要怎么设置才能正常返回值呢?我录制的脚本中,很多地方回放的时候都没有返回值,检查了一下,不是关联的问题~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    12#
     楼主| 发表于 2010-5-25 19:08:11 | 只看该作者
    我录制中用到的web_custom_request函数,为什么它提交数据给服务器的时候,服务器总是返回空值。正常来说是不会返回空值的。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    11#
     楼主| 发表于 2010-5-25 19:01:52 | 只看该作者

    回复 9# 的帖子

    修改了参数化的格式也不行,服务器还是返回空值~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    10#
    发表于 2010-5-25 16:54:22 | 只看该作者

    回复 9# 的帖子

    恩,这个问题是重点~~~
    发出去的BODY脚本认为是参数了,没当字符串
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    9#
    发表于 2010-5-25 16:41:07 | 只看该作者
    简单来说由于你返回的数据包是用{}来做的,而这个内容又正好是参数化的标志,所以会脚本回放出错,你修改一下参数化边界的格式就行了

    别的问题没看,只看了脚本回放的错误
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    8#
     楼主| 发表于 2010-5-25 16:35:03 | 只看该作者

    回复 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 编辑 ]
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    7#
    发表于 2010-5-25 15:47:49 | 只看该作者

    <DIV>TEST1</DIV>
    换成
    %3cDIV%3eTEST1%3c%2fDIV%3e
    试试
    你要抓的是HTTP协议从本机到服务器的内容是什么,其他没什么看的
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    6#
     楼主| 发表于 2010-5-25 11:49:25 | 只看该作者
    NewPost在后台的定义如下:

    AjaxPro.Utility.RegisterTypeForAjax
          [AjaxPro.AjaxMethod]
    //以上俩行能声明该函数能被前台调用
        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为自定义的后台存储提交内容的函数~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    5#
     楼主| 发表于 2010-5-25 11:46:59 | 只看该作者
    开发前台的代码是:var RetVa= StudyPlan_Student_Tutor_Index.NewPost(Plan_ID,UserID,2, postTitle,postContent).value;通过传入参数到后台定义的NewPost函数去提交内容,正确返回1到var RetVa中~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    4#
     楼主| 发表于 2010-5-25 11:43:28 | 只看该作者

    回复 3# 的帖子

    339是第一个web_custom_request的日志,发送的内容主要是 "Body={\"content\":\"<DIV>TEST1</DIV>\"}",是不是参数在web_custom_request传的不对啊~

    [ 本帖最后由 wangchao6656 于 2010-5-25 11:51 编辑 ]
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    3#
    发表于 2010-5-25 11:33:15 | 只看该作者
    339行 是哪个? 多关注一下发出去是什么马上就知道答案了
    录制出现 web_custom_request  有错误很常见
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    2#
     楼主| 发表于 2010-5-25 09:37:08 | 只看该作者
    顶起等待高手答复~
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

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

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

    GMT+8, 2024-9-28 15:22 , Processed in 0.081916 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

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