You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Jayesh Guru <ja...@gmail.com> on 2014/01/22 01:51:41 UTC

How can response xml values can be saved to a CSV file?

Hello,

I am trying to find a way to save XML response fields in a csv file in
SOAP/XML-RPC Request Sampler.

eg. in below response i want to save securityCode Values in a csv file

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns5:GenerateSecurityCodeResponse
xmlns:ns5="http://mpsys.ril.att.com/generatesecuritycoderesponse/v1" xmlns="
http://cio.att.com/commonheader/v3" xmlns:ns6="
http://mpsys.ril.att.com/verifysecuritycoderequest/v1" xmlns:ns7="
http://mpsys.ril.att.com/verifysecuritycoderesponse/v1" xmlns:ns2="
http://mpsys.ril.att.com/deletesecuritycoderequest/v1" xmlns:ns3="
http://mpsys.ril.att.com/deletesecuritycoderesponse/v1" xmlns:ns4="
http://mpsys.ril.att.com/generatesecuritycoderequest/v1
"><ns5:transactionId>GSBCss02</ns5:transactionId>
*<ns5:securityCode>43101112</ns5:securityCode>*
<ns5:securityCodeExpires>02102011</ns5:securityCodeExpires></ns5:GenerateSecurityCodeResponse></soapenv:Body></soapenv:Envelope>

Can Anyone help me in this regard?

*Thanks *
*Jayesh Guru*

Re: How can response xml values can be saved to a CSV file?

Posted by Deepak Shetty <sh...@gmail.com>.
This will kill the amount of load you can generate from Jmeter (think if
you run this in parallel with many threads). See sample_variables in
jmeter,properties to specify which variables you want written into the
standard JMeter output files


On Thu, Jan 23, 2014 at 10:44 AM, Jayesh Guru <ja...@gmail.com>wrote:

> Hi Kiran,
>
> Thanks for your response :)
> I got really a proper guidance to write the param to a CSV file.
> it didnt work for me using RegEx Extractor instead i used XPath Xtractor.
>
> Below are steps :
> *1) Xpath Extractor*
> Reference Name: xxx
> XPath Query: //*[local-name()='securityCode']/text()
> Default Value : 11111111
>
> *2) BeanShell PostProcessor*
> *Script:*
> String file1="C:/JMETER/GenSecCodes.csv";
> String yyy = vars.get("xxx");
> response = prev.getResponseDataAsString().toLowerCase(Locale.US);
> FileWriter fw = new FileWriter(file1,true);
> PrintWriter pw = new PrintWriter(fw);
> pw.println(yyy);
>
> //Flush the output to the file
> pw.flush();
>
> //Close the Print Writer
> pw.close();
>
> //Close the File Writer
> fw.close();
>
>
>
> *Thanks *
> *Jayesh Guru*
>
>
> On Wed, Jan 22, 2014 at 2:32 PM, KIRAN <rk...@gmail.com> wrote:
>
> > Hi Jayesh,
> >
> > You can do this by following the below steps:
> >
> > 1. Add Regular Expression Extractor to extract value using the settings:
> > Reference Name: xxx
> > Regular Expression: <TagName>(.+?)</TagName>
> > Template: $1$
> > Match No: -1
> >
> > 2. Add BeanShell PostProcessor and build java code to read the xml
> response
> > and writing it to a csv file.
> > I did the same kind of solution to extract values from the response xml.
> >
> > below is some code with which you can start with:
> >
> >
> --------------------------------------------------------------------------------------------
> > String yyy = vars.get("xxx");
> > response = prev.getResponseDataAsString().toLowerCase(Locale.US);
> > BufferedWriter outLoge = new BufferedWriter(new FileWriter("<CSV file
> > path>", true));
> > outLoge.write(yyy);
> >
> >
> --------------------------------------------------------------------------------------------
> > Hope this will give you a good start.
> >
> > Regards,
> > Kiran
> >
> >
> > On Tue, Jan 21, 2014 at 8:51 PM, sebb <se...@gmail.com> wrote:
> >
> > > On 22 January 2014 00:51, Jayesh Guru <ja...@gmail.com> wrote:
> > > > Hello,
> > > >
> > > > I am trying to find a way to save XML response fields in a csv file
> in
> > > > SOAP/XML-RPC Request Sampler.
> > >
> > > Not possible; responses can only be saved in XML files.
> > >
> > > > eg. in below response i want to save securityCode Values in a csv
> file
> > > >
> > > > <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
> xmlns:soapenv="
> > > > http://schemas.xmlsoap.org/soap/envelope/
> > > "><soapenv:Body><ns5:GenerateSecurityCodeResponse
> > > > xmlns:ns5="http://mpsys.ril.att.com/generatesecuritycoderesponse/v1"
> > > xmlns="
> > > > http://cio.att.com/commonheader/v3" xmlns:ns6="
> > > > http://mpsys.ril.att.com/verifysecuritycoderequest/v1" xmlns:ns7="
> > > > http://mpsys.ril.att.com/verifysecuritycoderesponse/v1" xmlns:ns2="
> > > > http://mpsys.ril.att.com/deletesecuritycoderequest/v1" xmlns:ns3="
> > > > http://mpsys.ril.att.com/deletesecuritycoderesponse/v1" xmlns:ns4="
> > > > http://mpsys.ril.att.com/generatesecuritycoderequest/v1
> > > > "><ns5:transactionId>GSBCss02</ns5:transactionId>
> > > > *<ns5:securityCode>43101112</ns5:securityCode>*
> > > >
> > >
> >
> <ns5:securityCodeExpires>02102011</ns5:securityCodeExpires></ns5:GenerateSecurityCodeResponse></soapenv:Body></soapenv:Envelope>
> > > >
> > > > Can Anyone help me in this regard?
> > > >
> > > > *Thanks *
> > > > *Jayesh Guru*
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > For additional commands, e-mail: user-help@jmeter.apache.org
> > >
> > >
> >
> >
> > --
> > Regards,
> > Kiran
> >
>

Re: How can response xml values can be saved to a CSV file?

Posted by Jayesh Guru <ja...@gmail.com>.
Hi Kiran,

Thanks for your response :)
I got really a proper guidance to write the param to a CSV file.
it didnt work for me using RegEx Extractor instead i used XPath Xtractor.

Below are steps :
*1) Xpath Extractor*
Reference Name: xxx
XPath Query: //*[local-name()='securityCode']/text()
Default Value : 11111111

*2) BeanShell PostProcessor*
*Script:*
String file1="C:/JMETER/GenSecCodes.csv";
String yyy = vars.get("xxx");
response = prev.getResponseDataAsString().toLowerCase(Locale.US);
FileWriter fw = new FileWriter(file1,true);
PrintWriter pw = new PrintWriter(fw);
pw.println(yyy);

//Flush the output to the file
pw.flush();

//Close the Print Writer
pw.close();

//Close the File Writer
fw.close();



*Thanks *
*Jayesh Guru*


On Wed, Jan 22, 2014 at 2:32 PM, KIRAN <rk...@gmail.com> wrote:

> Hi Jayesh,
>
> You can do this by following the below steps:
>
> 1. Add Regular Expression Extractor to extract value using the settings:
> Reference Name: xxx
> Regular Expression: <TagName>(.+?)</TagName>
> Template: $1$
> Match No: -1
>
> 2. Add BeanShell PostProcessor and build java code to read the xml response
> and writing it to a csv file.
> I did the same kind of solution to extract values from the response xml.
>
> below is some code with which you can start with:
>
> --------------------------------------------------------------------------------------------
> String yyy = vars.get("xxx");
> response = prev.getResponseDataAsString().toLowerCase(Locale.US);
> BufferedWriter outLoge = new BufferedWriter(new FileWriter("<CSV file
> path>", true));
> outLoge.write(yyy);
>
> --------------------------------------------------------------------------------------------
> Hope this will give you a good start.
>
> Regards,
> Kiran
>
>
> On Tue, Jan 21, 2014 at 8:51 PM, sebb <se...@gmail.com> wrote:
>
> > On 22 January 2014 00:51, Jayesh Guru <ja...@gmail.com> wrote:
> > > Hello,
> > >
> > > I am trying to find a way to save XML response fields in a csv file in
> > > SOAP/XML-RPC Request Sampler.
> >
> > Not possible; responses can only be saved in XML files.
> >
> > > eg. in below response i want to save securityCode Values in a csv file
> > >
> > > <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
> > > http://schemas.xmlsoap.org/soap/envelope/
> > "><soapenv:Body><ns5:GenerateSecurityCodeResponse
> > > xmlns:ns5="http://mpsys.ril.att.com/generatesecuritycoderesponse/v1"
> > xmlns="
> > > http://cio.att.com/commonheader/v3" xmlns:ns6="
> > > http://mpsys.ril.att.com/verifysecuritycoderequest/v1" xmlns:ns7="
> > > http://mpsys.ril.att.com/verifysecuritycoderesponse/v1" xmlns:ns2="
> > > http://mpsys.ril.att.com/deletesecuritycoderequest/v1" xmlns:ns3="
> > > http://mpsys.ril.att.com/deletesecuritycoderesponse/v1" xmlns:ns4="
> > > http://mpsys.ril.att.com/generatesecuritycoderequest/v1
> > > "><ns5:transactionId>GSBCss02</ns5:transactionId>
> > > *<ns5:securityCode>43101112</ns5:securityCode>*
> > >
> >
> <ns5:securityCodeExpires>02102011</ns5:securityCodeExpires></ns5:GenerateSecurityCodeResponse></soapenv:Body></soapenv:Envelope>
> > >
> > > Can Anyone help me in this regard?
> > >
> > > *Thanks *
> > > *Jayesh Guru*
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
> >
> >
>
>
> --
> Regards,
> Kiran
>

Re: How can response xml values can be saved to a CSV file?

Posted by KIRAN <rk...@gmail.com>.
Hi Jayesh,

You can do this by following the below steps:

1. Add Regular Expression Extractor to extract value using the settings:
Reference Name: xxx
Regular Expression: <TagName>(.+?)</TagName>
Template: $1$
Match No: -1

2. Add BeanShell PostProcessor and build java code to read the xml response
and writing it to a csv file.
I did the same kind of solution to extract values from the response xml.

below is some code with which you can start with:
--------------------------------------------------------------------------------------------
String yyy = vars.get("xxx");
response = prev.getResponseDataAsString().toLowerCase(Locale.US);
BufferedWriter outLoge = new BufferedWriter(new FileWriter("<CSV file
path>", true));
outLoge.write(yyy);
--------------------------------------------------------------------------------------------
Hope this will give you a good start.

Regards,
Kiran


On Tue, Jan 21, 2014 at 8:51 PM, sebb <se...@gmail.com> wrote:

> On 22 January 2014 00:51, Jayesh Guru <ja...@gmail.com> wrote:
> > Hello,
> >
> > I am trying to find a way to save XML response fields in a csv file in
> > SOAP/XML-RPC Request Sampler.
>
> Not possible; responses can only be saved in XML files.
>
> > eg. in below response i want to save securityCode Values in a csv file
> >
> > <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
> > http://schemas.xmlsoap.org/soap/envelope/
> "><soapenv:Body><ns5:GenerateSecurityCodeResponse
> > xmlns:ns5="http://mpsys.ril.att.com/generatesecuritycoderesponse/v1"
> xmlns="
> > http://cio.att.com/commonheader/v3" xmlns:ns6="
> > http://mpsys.ril.att.com/verifysecuritycoderequest/v1" xmlns:ns7="
> > http://mpsys.ril.att.com/verifysecuritycoderesponse/v1" xmlns:ns2="
> > http://mpsys.ril.att.com/deletesecuritycoderequest/v1" xmlns:ns3="
> > http://mpsys.ril.att.com/deletesecuritycoderesponse/v1" xmlns:ns4="
> > http://mpsys.ril.att.com/generatesecuritycoderequest/v1
> > "><ns5:transactionId>GSBCss02</ns5:transactionId>
> > *<ns5:securityCode>43101112</ns5:securityCode>*
> >
> <ns5:securityCodeExpires>02102011</ns5:securityCodeExpires></ns5:GenerateSecurityCodeResponse></soapenv:Body></soapenv:Envelope>
> >
> > Can Anyone help me in this regard?
> >
> > *Thanks *
> > *Jayesh Guru*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>


-- 
Regards,
Kiran

Re: How can response xml values can be saved to a CSV file?

Posted by sebb <se...@gmail.com>.
On 22 January 2014 00:51, Jayesh Guru <ja...@gmail.com> wrote:
> Hello,
>
> I am trying to find a way to save XML response fields in a csv file in
> SOAP/XML-RPC Request Sampler.

Not possible; responses can only be saved in XML files.

> eg. in below response i want to save securityCode Values in a csv file
>
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
> http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns5:GenerateSecurityCodeResponse
> xmlns:ns5="http://mpsys.ril.att.com/generatesecuritycoderesponse/v1" xmlns="
> http://cio.att.com/commonheader/v3" xmlns:ns6="
> http://mpsys.ril.att.com/verifysecuritycoderequest/v1" xmlns:ns7="
> http://mpsys.ril.att.com/verifysecuritycoderesponse/v1" xmlns:ns2="
> http://mpsys.ril.att.com/deletesecuritycoderequest/v1" xmlns:ns3="
> http://mpsys.ril.att.com/deletesecuritycoderesponse/v1" xmlns:ns4="
> http://mpsys.ril.att.com/generatesecuritycoderequest/v1
> "><ns5:transactionId>GSBCss02</ns5:transactionId>
> *<ns5:securityCode>43101112</ns5:securityCode>*
> <ns5:securityCodeExpires>02102011</ns5:securityCodeExpires></ns5:GenerateSecurityCodeResponse></soapenv:Body></soapenv:Envelope>
>
> Can Anyone help me in this regard?
>
> *Thanks *
> *Jayesh Guru*

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org