Loadrunner中使用lr_xml_get_values()获取服务端返回的字符串LcsId,LcsId为double,需要将该值转换为 int 后传入下一次请求中。

  报错如下:Error is : Exception Occurred while invoking WriteObject method; Debugging information: cause-exception : java.lang.NumberFormatException.

  解决方法:

  需要对flex_amf_call()的Response进行数据提取,提取的数据为double,但是submit.c中需要int,于是牵扯数据类型转换。

  本以为只需要使用一个整型变量transferedLcsId接收,然后在submit.c中将<string>transferedLcsId</string><int>***</int>的“***”替换为“transferedLcsId”,就好了,但是始终报错,查看扩展日志后发现,是格式转换的问题;

  在师傅的帮助下,添加lr_save_int()将transferedLcsId保存为int,在得以解决,如下。

错误代码:

int  transferedLcsId;    //存放在globals.h文件中

flex_amf_call(

 "AMF3_call_16",

 "ResponseParameter=response",

);

lr_xml_get_values("XML={response}",

 "Query=//string[contains(text(),'id')]/following::double",

 "ValueParam=id",

 LAST

);

transferedLcsId = atoi(lr_eval_string ("{id}"));

解决后代码:

int  transferedLcsId;    //存放在globals.h文件中

flex_amf_call(

"AMF3_call_16",

 "ResponseParameter=response",

);

lr_xml_get_values("XML={response}",

 "Query=//string[contains(text(),'id')]/following::double",

 "ValueParam=id",

 LAST

);

transferedLcsId = atoi(lr_eval_string ("{id}"));

lr_save_int (transferedLcsId,"transferedLcsId");  //重要的保存

flex_amf_call(

 "AMF3_call_17",

 "<string>transferedLcsId</string><int>transferedLcsId</int>"

);

flex_amf_call(

 "AMF3_call_17",

 "<string>transferedLcsId</string><int> { transferedLcsId } </int>"

);

  总结:虽然transferedLcsId是整型变量,但是需要使用lr_save_int函数将该变量用loadrunner可以识别的参数化方式保存起来,即需要从C语言格式转换为LR可以识别的格式,再应用到录制的脚本中。

  lr_save_int在man手册中的功能解释:Saves an integer to a parameter.类似的还有:

LoadRunner ERROR: java.lang.NumberFormatException的更多相关文章

  1. 使用JedisCluster出现异常:java.lang.NumberFormatException

    在使用JedisCluster进行测试时出现如下异常: java.lang.NumberFormatException: For input string: "7004@17004" ...

  2. SpringBoot整合Swagger2案例,以及报错:java.lang.NumberFormatException: For input string: ""原因和解决办法

    原文链接:https://blog.csdn.net/weixin_43724369/article/details/89341949 SpringBoot整合Swagger2案例 先说SpringB ...

  3. maven项目中使用redis集群报错: java.lang.NumberFormatException: For input string: "7006@17006"

    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [redis.client ...

  4. javaweb报错:java.lang.NumberFormatException: null

    报错环境: JSP向Severlet页面传值,当Serverlet页执行以下语句时,后台日志报错 int softType = Integer.parseInt(request.getParamete ...

  5. ERROR: java.lang.NullPointerException的一种情况

    java.lang.NullPointerException错误,错误原因就是以下六条没配置完: 1.JAVA环境配置正确.2.源码里面的包没有与tomcat的包冲突.3.把数据库文件给导入到了SQL ...

  6. error:java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long

    问题:mysql中id存的是int(10),java代码中的id为long,转不过去 解决:mysql中的int要是需要转到java中的long,需要选择unsigned这个选项,即if(unsign ...

  7. maven项目中使用redis集群报错: java.lang.NumberFormatException: For input string: "7001@17001"

    解决:由于redis集群的采用的版本是2.7的,在maven的pom.xml中将jedis的版本改成2.9的就可以了

  8. java.lang.NumberFormatException: Infinite or NaN

      1.异常提示: java.lang.NumberFormatException: Infinite or NaN 2.原因:无法格式化的数字,此数字要么不是个数字,要么是无穷大的数字,从而导致 B ...

  9. java.lang.NumberFormatException:For input string:"undefined"

    在将字符串转换为数字时导致此错误,解决此问题的思路: 1.添加 try catch语句 2.判断字符串是否为数字,将介绍java中判断字符串是否为数字的方法的几种方法 发生错误的代码: java.la ...

随机推荐

  1. PhpStorm创建Drupal模块项目开发教程(3)

    rush是 Drupal的脚本界面,PhpStorm的命令行工具支持Drush 5.8和更高版本. 接下来就Drush配置和基本操作进行设置,首先点击打开Settings | Command Line ...

  2. String split

    这个方法看似简单,其实如果使用不当,会出现很多问题 System.out.println(":ab:cd:ef::".split(":").length);// ...

  3. java比较版本号

    java比较版本号,比如1.0.3和1.2.1相比较考虑到可以用String的compareTo()方法,代码如下: public class MainClass { public static vo ...

  4. angular的路由

    AngularJS 路由允许我们通过不同的 URL 访问不同的内容. 通过 AngularJS 可以实现多视图的单页Web应用(single page web application,SPA). 下面 ...

  5. 后端学 Angular 2 —— 组件间通信

    1. 父组件向子组件传递信息 使用@Input 子组件的属性用 @Input 进行修饰,在父组件的模板中绑定变量 例子: import { Component, OnInit, Input } fro ...

  6. 【前端】在Gulp中使用Babel

    Install $ npm install --save-dev gulp-babel babel-preset-es2015 用法1: const gulp = require('gulp'); c ...

  7. mac上eclipse用gdb调试(转)

    mac上eclipse用gdb调试 With its new OS release, Apple has discontinued the use of GDB in OS X. Since 2005 ...

  8. Obtaining Query Count Without executing a Query in Oracle D2k

    Obtaining Query Count Without executing a Query in Oracle D2k Obtaining a count of records that will ...

  9. javaScript 验证表单提交

    <script type="text/javascript">      function $(id) {          return document.getEl ...

  10. consul模板的说明2

    保证模板的正常执行 使用||true $ consul-template -template "in.ctmpl:out.file:service nginx restart || true ...