jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nirodha Pramod <niro...@wso2.com>
Subject Issue with SoapSampler.setXmlData()
Date Wed, 01 Feb 2012 17:43:16 GMT
Hi,

I have a scenario where I read the soap request from a file and I need to
replace some variables in the soap request with the values in a CSV file.
Since Jmeter does not support mapping CSV values to a soap request on a
file I had to use a Beanshell preprocessor also. I have given the script
below. Everything works perfect except that the ---
soapSampler.setXmlData(soapRequest); ---- line at the bottom. I was
debugging the script with a print() line after each line and I found out
that the soap request mapped with the values in the CSV corresponding to
each thread, but the problem is the new soap requst does not get attached
the sampler, before it is sent. It sends the raw request in the file,
instead.  Please have a look, Have I done anything wrong?


import org.apache.jmeter.protocol.http.sampler.SoapSampler;
import java.io.*;

String paramString = props.getProperty("csvread.variabes");
String []arr = paramString.split(",");
ArrayList params= new ArrayList(Arrays.asList(arr));
vars.putObject("paramsArr", params);



SoapSampler soapSampler = (SoapSampler) sampler;
BufferedReader xmlReader = new BufferedReader(new InputStreamReader(new
FileInputStream(soapSampler.getXmlFile()),
java.nio.charset.Charset.forName("UTF-8")));
StringBuffer xmlData = new StringBuffer();
String line;
while( (line = xmlReader.readLine()) != null) {
xmlData.append(line).append('\n'); }
String soapRequest = xmlData.toString();
ArrayList parameters = vars.getObject("paramsArr");

for(int i=0; i < parameters.size(); i++)
{
    soapRequest = soapRequest.replaceFirst("#" + parameters.get(i) + "#" ,
vars.get(parameters.get(i)) );
 }
//print("XML set: " + soapRequest);
*soapSampler.setXmlData(soapRequest);*
print("XML set: " + soapSampler.getXMLdata());


-- 
*Nirodha Gallage*
Software Engineer, QA.
WSO2 Inc.: http://wso2.com/
Email: nirodha@wso2.com   Mobile: +94716429078

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message