Thanks, will try that. /Nirodha
On Wed, Feb 1, 2012 at 11:39 PM, sebb <[email protected]> wrote: > On 1 February 2012 17:43, Nirodha Pramod <[email protected]> wrote: > > 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? > > setXmlData is used to set the GUI data field, which is not used if > there is a file name. > > You have several options: > * clear the fileName field > * put the data in the GUI field in the first place, in which case > JMeter will do the substitution for you > * create a temporary file with updated contents - remember to choose a > file name that is unique to the thread - and make sure that the file > name field is updated accordingly. > * preprocess the files before the test starts and send the correct one. > > > > > 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: [email protected] Mobile: +94716429078 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- *Nirodha Gallage* Software Engineer, QA. WSO2 Inc.: http://wso2.com/ Email: [email protected] Mobile: +94716429078
