51Testing软件测试论坛

标题: 手动关联-LR返回XML格式文件,返回值取不到问题 [打印本页]

作者: wayneling    时间: 2015-9-7 14:18
标题: 手动关联-LR返回XML格式文件,返回值取不到问题
录制脚本时选择的是多协议: Web (HTTP/HTML), Web Services  
现在是我要从返回文件中读取数据,然后参数化
返回文件是XML格式的,代码如下
  <?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.starlims.com/webservices/" xmlns:types="http://www.starlims.com/webservices/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <tns:RunActionResponse>
  <RunActionResult xsi:type="xsd:int">29001100</RunActionResult>
  </tns:RunActionResponse>
  </soap:Body>
  </soap:Envelope>
我要取29001100这个值,使用注册函数web_reg_save_param_ex(),LR中相关代码如下


web_reg_save_param_ex(
                "ParamName=bai",
                "LB=<RunActionResult xsi:type=\"xsd:int\">",
                "RB=",
                "NotFound=error",
                SEARCH_FILTERS,
                "Scope=ALL",
                "ContentType=text/xml",
                LAST);

        soap_request("StepName=RunAction_24",
                "URL=http://192.168.0.56/STARLIMS10.da/services/generic.asmx",
                "SOAPEnvelope="
                        "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?>"
                        "<soap:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:types=\"http://www.starlims.com/webservices/encodedTypes\" xmlns:tns=\"http://www.starlims.com/webservices/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                                "<soap:Body soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
                                        "<tns:RunAction>"
                                                "<actionID xsi:type=\"xsd:string\">SampleLogin.AddSample</actionID>"
                                                "<parameters href=\"#id1\"></parameters>"
                                        "</tns:RunAction>"
                                        "<soapenc:Array soapenc:arrayType=\"xsd:anyType[1]\" id=\"id1\">"
                                                "<Item xsi:type=\"xsd:string\">131410015</Item>"
                                        "</soapenc:Array>"
                                "</soap:Body>"
                        "</soap:Envelope>",
                "Snapshot=t182.inf",
                "ResponseParam=response",
                LAST);

soap_request("StepName=RunAction_24",.....这个是返回我要取值的所在函数,我把注册函数放在了请求函数之前
运行脚本,一直报错,未匹配到记录
Action.c(2062): Error -35061: No match found for the requested parameter "bai". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size          [MsgId: MERR-35061]
Action.c(2062): web_url("RUNTIME_SUPPORT.GetData.lims_4") highest severity level was "ERROR", 1375 body bytes, 219 header bytes          [MsgId: MMSG-26388]

各位高手帮我看看,这个问题困扰我好几天了,多谢啦!!☆⌒(*^-゜)
作者: wayneling    时间: 2015-9-7 16:49
已经解决了,使用LR自带的函数可以获取到
切换到TREE模式,找到返回值的那一行,右键-选择save value in parameter
生成脚本如下        lr_xml_get_values("XML={response}",
                          "FastQuery=/Envelope/Body/RunActionResponse/RunActionResult",
                          "ValueParam=a",
                          LAST);

        lr_message( "_______%@@@@@@@@@%s",
                lr_eval_string("{a}") );
作者: wayneling    时间: 2015-9-7 16:51
FD
作者: wayneling    时间: 2015-9-7 16:52
已经解决了,使用LR自带的函数可以获取到
切换到TREE模式,找到返回值的那一行,右键-选择save value in parameter
生成脚本如下        lr_xml_get_values("XML={response}",
                          "FastQuery=/Envelope/Body/RunActionResponse/RunActionResult",
                          "ValueParam=a",
                          LAST);

        lr_message( "_______%@@@@@@@@@%s",
                lr_eval_string("{a}") );




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2