jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nirodha Pramod <niro...@wso2.com>
Subject Re: Issue with SoapSampler.setXmlData()
Date Wed, 01 Feb 2012 20:22:08 GMT
Yes, it worked after removing the file path from the file area.

Thanks

On Wed, Feb 1, 2012 at 11:44 PM, Nirodha Pramod <nirodha@wso2.com> wrote:

> Thanks, will try that.
>
> /Nirodha
>
>
> On Wed, Feb 1, 2012 at 11:39 PM, sebb <sebbaz@gmail.com> wrote:
>
>> On 1 February 2012 17:43, Nirodha Pramod <nirodha@wso2.com> 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: nirodha@wso2.com   Mobile: +94716429078
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>>
>>
>
>
> --
> *Nirodha Gallage*
>
> Software Engineer, QA.
> WSO2 Inc.: http://wso2.com/
> Email: nirodha@wso2.com   Mobile: +94716429078
>
>


-- 
*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