51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3270|回复: 10
打印 上一主题 下一主题

[原创] 请高手帮忙-测试Flex协议时,解析服务器端返回的xm数据l

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2010-8-10 15:46:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用http协议来对flex的网站进行测试;由于服务器端和客户端都是基于xml进行文件的交互,所以想用loadrunner自带的lr_xml_get_values函数保存一些服务器端的结果,用于数据的关联。可是lr_xml_get_values出现错误,如下的红色字体

不知道问题出现在哪里,请大家帮忙,谢谢!

代码片段:

// 注册函数,用于将服务器回包的body部分保存下来
web_reg_save_param("xmlcontent", "LB=", "RB=", "Search=BODY", LAST);

//向服务器提交post,(使用的是xml格式)
web_custom_request("counter**_2",
        "URL=http://loanoriginationqa:8080/lo-web/service/counter**/?_method=PUT&uniqueId=Tue%20Aug%2010%2014:05:42%20GMT+0800%202010",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/xml",
        "Referer=http://loanoriginationqa:8080/lo-web/flex/main.swf",
        "Snapshot=t14.inf",
        "Mode=HTTP",
        "EncType=text/xml",
        "Body=<counter**>\n  <entityGroup>\n    <groupId>181</groupId>\n    <groupName>LO_QA</groupName>\n  </entityGroup>\n  <countryOfIncorporation>\n    <code>AF</code>\n    <name>Afghanistan</name>\n  </countryOfIncorporation>\n  <description>Created By Yang</description>\n  <mailingCity>TestCity</mailingCity>\n  <mailingZipCode>110006</mailingZipCode>\n  <industry>\n    <code>25401010</code>\n    <description>Advertising</description>\n  </industry>\n  <type>\n    <code>ASS</code>\n    <description"
                ">Insurance</description>\n  </type>\n  <status>New</status>\n  <mailingState>TestCity</mailingState>\n  <cifNumber>1111</cifNumber>\n  <businessRegistrationNo>000002</businessRegistrationNo>\n  <withBankSince>08-01-2012</withBankSince>\n  <relationship/>\n  <mailingCountry>\n    <code>CN</code>\n    <name>China</name>\n  </mailingCountry>\n  <shortName>company_2</shortName>\n  <longName>company</longName>\n  <contacts/>\n  <mailingAddress1>No details</mailingAddress1>\n</counter**>",
        LAST);

    lr_output_message(lr_eval_string("{xmlcontent}"));//通过打印的数据可以看出,xmlcontent正确的保存了服务器端返回的数据


    lr_xml_get_values("XML={xmlcontent}", "ValueParam=Counter**ID", "Query=/counter**/code");//这步会出现错误提示:Error: C interpreter run time error: Action.c (334):  Error -- memory violation : Exception ACCESS_VIOLATION received

    lr_output_message(lr_eval_string("Query result = {Counter**ID}"));//由于上步的错误,没运行到此步骤就推出了

服务器端和客户端交互的数据格式:
客户端提交:


<counter**>
<mailingState>TestCity</mailingState>
<cifNumber>1111</cifNumber>
<businessRegistrationNo>000003</businessRegistrationNo>
<relationship/>
<type>
<code>ASS</code>
<description>Insurance</description>
</type>
<mailingCountry>
<code>AF</code>
<name>Afghanistan</name>
</mailingCountry>
<status>New</status>
<contacts/>
<mailingAddress1>No details</mailingAddress1>
<mailingZipCode>110006</mailingZipCode>
<entityGroup>
<groupId>181</groupId>
<groupName>LO_QA</groupName>
</entityGroup>
<shortName>company_3</shortName>
<longName>company</longName>
<countryOfIncorporation>
<code>AF</code>
<name>Afghanistan</name>
</countryOfIncorporation>
<mailingCity>TestCity</mailingCity>
<industry>
<code>25401010</code>
<description>Advertising</description>
</industry>
<description>Created By Yang</description>
</counter**>


服务器端返回:

<counter**>
<code>764</code>
<shortName>company_3</shortName>
<longName>company</longName>
<description>Created By Yang</description>
<type>
<code>ASS</code>
<description>Insurance</description>
</type>
<cifNumber>1111</cifNumber>
<businessRegistrationNo>000003</businessRegistrationNo>
<countryOfIncorporation>
<code>AF</code>
<name>Afghanistan</name>
</countryOfIncorporation>
<industry>
<code>25401010</code>
<description>Advertising</description>
</industry>
<status>New</status>
<mailingAddress1>No details</mailingAddress1>
<mailingCity>TestCity</mailingCity>
<mailingZipCode>110006</mailingZipCode>
<mailingState>TestCity</mailingState>
<mailingCountry>
<code>AF</code>
<name>Afghanistan</name>
</mailingCountry>
<contacts/>
<relationship/>
<entityGroup>
<groupId>181</groupId>
<groupName>LO_QA</groupName>
</entityGroup>
</counter**>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
 楼主| 发表于 2010-8-10 15:50:17 | 只看该作者

把出错那部分单列出来,顺便顶顶

lr_xml_get_values("XML={xmlcontent}", "ValueParam=Counter**ID", "Query=/colunter**/code");

Error: C interpreter run time error: Action.c (334):  Error -- memory violation : Exception ACCESS_VIOLATION received.
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2010-8-10 15:51:33 | 只看该作者

出现敏感字,竟然被××了

lr_xml_get_values("XML={xmlcontent}", "ValueParam=CounterpartID", "Query=/colunterpart/code");

Error: C interpreter run time error: Action.c (334):  Error -- memory violation : Exception ACCESS_VIOLATION received.
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2010-8-10 16:11:05 | 只看该作者
把xml里   **   给弄掉。。。
回复 支持 反对

使用道具 举报

该用户从未签到

5#
 楼主| 发表于 2010-8-10 16:19:42 | 只看该作者

回复 4# 的帖子

这个是用了**上的一个英文词语,被屏蔽了,呵呵;程序中是没问题的
回复 支持 反对

使用道具 举报

该用户从未签到

6#
发表于 2010-8-10 16:24:13 | 只看该作者
lr_xml_get_values("XML={xmlcontent}", "ValueParam=CounterpartID", "Query=//code",LAST);

试了 这样是可以的,如果你这句会报错的话,那就。。。

改晚了,刚想说,呵呵

[ 本帖最后由 skyzhu 于 2010-8-10 17:41 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

7#
 楼主| 发表于 2010-8-10 17:17:24 | 只看该作者

谢谢大家,问题解决了

我上网查了一下
Exception ACCESS_VIOLATION
Web (HTTP/HTML) scripts in LoadRunner are implemented using C programming language. And like always with C, you should remember about some basics. One of them is that few string handling function can return NULL value instead of correct pointer which will definitely lead to exception like the one below:

   1.Action.c(7): Error: C interpreter run time error: Action.c (7):  Error — memory violation : Exception ACCESS_VIOLATION received.

Basically if you see message like this, it is not any internal LoadRunner error. It means that you made a mistake in your script and you need to fix it.

他说 Exception ACCESS_VIOLATION received不是LoadRunner内部的错误,而是C代码的函数写的有问题;所以我反复对比了一下,发现是问题是
lr_xml_get_values("XML={xmlcontent}", "ValueParam=CounterID", "Query=/counter/code");
改成
lr_xml_get_values("XML={xmlcontent}", "ValueParam=CounterID", "Query=/counter/code", LAST);
就好了。
再次感谢大家的关注!!!
回复 支持 反对

使用道具 举报

该用户从未签到

8#
发表于 2010-8-10 17:50:18 | 只看该作者
额,这个问题。。。还好解决了,否则大家要纠结很久,代码写错害死人
回复 支持 反对

使用道具 举报

该用户从未签到

9#
发表于 2010-8-10 17:58:25 | 只看该作者
云老师介绍socket时候参数写反了,耽误好多时间哦
回复 支持 反对

使用道具 举报

该用户从未签到

10#
发表于 2010-8-10 20:41:13 | 只看该作者
后面我才发现,郁闷啊
回复 支持 反对

使用道具 举报

  • TA的每日心情
    奋斗
    2022-5-8 19:23
  • 签到天数: 137 天

    连续签到: 1 天

    [LV.7]测试师长

    11#
    发表于 2010-8-10 22:24:03 | 只看该作者
    汗,一个非常简单的语法错误,不过这类问题,自己看的话,还真难发现
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

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

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

    GMT+8, 2024-9-21 06:04 , Processed in 0.078201 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

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