简体   繁体   English

JMeter为CSV文件中的SOAP / XML数据添加了额外的引号

[英]JMeter adding extra quotes to SOAP/XML data from CSV file

I am setting up JMeter testing of a SOAP/XML service. 我正在设置SOAP / XML服务的JMeter测试。 When I did a manual test, it worked fine, when I used the exact same data from a csv file, JMeter is adding an extra quote for every one it finds in the Soap/XML-RPC Data which is supplied as a variable from the CSV file. 当我进行手动测试时,当我使用来自csv文件的完全相同的数据时,它运行良好,JMeter为其在Soap / XML-RPC数据中找到的每个数据添加了一个额外的报价,该报价作为变量提供。 CSV档案。

Here's the raw data - extracted from the CSV file: 这是原始数据-从CSV文件中提取:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-  ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.xxxxyyyy.zzzz.com/ProductDetails"><SOAP-ENV:Body><ns1:ProductDetailsRequestDocument><ContextInfo><StoreId>10151</StoreId><CatalogId>10551</CatalogId><LangId>-1</LangId></ContextInfo><SKU>707138</SKU></ns1:ProductDetailsRequestDocument></SOAP-ENV:Body></SOAP-ENV:Envelope>

When I paste that into the Soap/XML-RPC Data window, it sends it as-is..however, when I setup CVS Data Set Config to pull the values from a CSV file (delimited by | ), it doubles every " found - as in this example from the View Results Tree Request: 当我将其粘贴到Soap / XML-RPC数据窗口中时,它按原样发送。但是,当我设置CVS数据集配置以从CSV文件(由|分隔)中提取值时,它会将找到的每个“ -如本示例中的查看结果树请求中所示:

<?xml version=""1.0"" encoding=""UTF-8""?><SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ns1=""http://www.xxxxyyyyzzzz.com/ProductDetails""><SOAP-ENV:Body><ns1:ProductDetailsRequestDocument><ContextInfo><StoreId>10151</StoreId><CatalogId>10551</CatalogId><LangId>-1</LangId></ContextInfo><SKU>529346</SKU></ns1:ProductDetailsRequestDocument></SOAP-ENV:Body></SOAP-ENV:Envelope>"

Which of course, causes the request to fail with this sort of error as part of the response: 当然,这会导致请求失败,并在响应中包含此类错误:

org.xml.sax.SAXParseException: XML version &quot;&quot;1.0&quot; is not supported

If I change "Allow Quoted Data" in the CVS Data Set config window to "true" it fails with notthing but Error on every request, as the first variable is simply passed as the name and not the CSV value. 如果将CVS数据集配置窗口中的“允许带引号的数据”更改为“ true”,它将失败,但在每个请求上均出现错误,因为第一个变量只是作为名称而不是CSV值传递。

I can change my parsing script to strip out the quoates ofmr the SOAP/XML portion, but unsure if that will work, and wonder why I should have to do this, or if there is a more elegant way to approach this. 我可以更改解析脚本以去除SOAP / XML部分的数量,但是不确定是否可以使用,并不确定为什么我必须这样做,或者是否有更优雅的方法来实现这一点。 Thanks! 谢谢!

You can remove double quotation marks from request using the following approach: 您可以使用以下方法从请求中删除双引号:

  1. Add a Beanshell PreProcessor as a child of your SOAP/XML-RPC request Beanshell预处理器添加为SOAP / XML-RPC请求的子代
  2. Put the following code into PreProcessor's "Script" area: 将以下代码放入PreProcessor的“脚本”区域:

     String data = sampler.getXmlData(); data = data.replaceAll("\\"\\"","\\""); sampler.setXmlData(data); 
  3. Save and execute your test. 保存并执行测试。 You can view request details using View Results Tree listener to verify that XML being sent doesn't contain trailing quotation marks. 您可以使用“ 查看结果树”侦听器查看请求详细信息,以验证发送的XML不包含尾引号。 Don't forget to disable/remove the listener for real load test. 不要忘记禁用/删除监听器以进行实际负载测试。

See How to use BeanShell: JMeter's favorite built-in component for more information on scripting, built-in types which can be used and sample scripts cookbook. 请参阅如何使用BeanShell:JMeter最喜欢的内置组件 ,以获取有关脚本,可以使用的内置类型和示例脚本食谱的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM