You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by thorr09 <bv...@gmail.com> on 2010/04/23 13:22:43 UTC

Jmeter preprocessors, Java code...

How is it possible to run Java code and write the returned value in the
request in a Sampler? Does BeanShell support Java code, or can it call
somehow java code?
-- 
View this message in context: http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28340073.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: Jmeter preprocessors, Java code...

Posted by sebb <se...@gmail.com>.
On 26/04/2010, thorr09 <bv...@gmail.com> wrote:
>
>  Thanks for the reply
>
>
>  >Have you tried using:
>  >
>  >http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file
>  >
>  >That may well do all/most of what you want.
>
>
> I have tried that now. This way I get the whole response as an xml file. The
>  actual data which was returned from the SOAP method is between the follwing
>  tags:
>
>  <convertReturn xsi:type="xsd:base64Binary">
>  GFydHhyZWYKMzUzMDkKJSVFT0YK</convertReturn>
>
>  I can write another Java function which could read the data transform it
>  from Base64 to byte[] and write the actual result file to disk, but I just
>  hoped it goes more simplier. I hoped in a post-processor I can somehow get
>  that Base64 data transform it to byte[] and write the file to disk.
>

This is also possible.

You can use a BeanShell PostProcessor to read the response:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor

The "prev" var is of type SampleResult.

But why do you need the binary version of the response?
If it is needed later for another sampler, then it is likely that the
binary data will need to be re-encoded anyway.

>
>  sebb-2-2 wrote:
>  >
>  > On 26/04/2010, thorr09 <bv...@gmail.com> wrote:
>  >>
>  >>  Hi guys!
>  >>  Sorry for not greeting you on friday...my mistake.
>  >>  Thanks for the reply...I have another question. I want to write a
>  >> Beanshell
>  >>  post processor now which will write the binary result data of a SOAP
>  >> call to
>  >>  a file. How do I have access to that data in the BeanShell script? The
>  >> data
>  >>  should be present in the response, how could I read it from there maybe?
>  >>  Thanks in advance,
>  >>  Cheers,
>  >>
>  >
>  > Have you tried using:
>  >
>  > http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file
>  >
>  > That may well do all/most of what you want.
>  >
>  >>
>  >>  TincaTibo wrote:
>  >>  >
>  >>  > Hello (Don't you know the netiquette?)
>  >>  >
>  >>  > Exactly, you can use Beanshell, as Beanshell can be considered as
>  >>  > scripting
>  >>  > in Java. So you can call whatever Java you wrote, create or modify
>  >> JMeter
>  >>  > Variables in the script and then use it wherever you want.
>  >>  > See
>  >>  >
>  >> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_Sampler
>  >>  > And *for full details on using BeanShell, please see the BeanShell
>  >>  > web-site
>  >>  > at http://www.beanshell.org/*
>  >>  >
>  >>  > Regards,
>  >>  > Tibo
>  >>  >
>  >>  > On Fri, Apr 23, 2010 at 13:22, thorr09 <bv...@gmail.com> wrote:
>  >>  >
>  >>  >>
>  >>  >> How is it possible to run Java code and write the returned value in
>  >> the
>  >>  >> request in a Sampler? Does BeanShell support Java code, or can it
>  >> call
>  >>  >> somehow java code?
>  >>  >> --
>  >>  >> View this message in context:
>  >>  >>
>  >> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28340073.html
>  >>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>  >>  >>
>  >>  >>
>  >>  >> ---------------------------------------------------------------------
>  >>  >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >>  >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>  >>
>  >>  >>
>  >>  >
>  >>  >
>  >>
>  >>
>  >> --
>  >>  View this message in context:
>  >> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28362934.html
>  >>
>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >>  ---------------------------------------------------------------------
>  >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >
>  >
>  >
>
>  --
>
> View this message in context: http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28364086.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

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


Re: Jmeter preprocessors, Java code...

Posted by thorr09 <bv...@gmail.com>.
Thanks guys...you all helped me a lot!

-- 
View this message in context: http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28364419.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: Jmeter preprocessors, Java code...

Posted by Thibaut Raballand <th...@gmail.com>.
Hi,

You can access response data from Beanshell thanks to the variables provided
by JMeter:
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor

   - prev - (SampleResult) - gives access to the previous SampleResult

Here is the documentation for this object :

   -
   http://jakarta.apache.org/jmeter/api/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.html

You can then use methods : getResponseData or getResponseDataAsString to get
the response from the server.

To save to a file, you can use usual Java fonctions.

Rgds,
Tibo


On Mon, Apr 26, 2010 at 14:03, thorr09 <bv...@gmail.com> wrote:

>
> Thanks for the reply
>
> >Have you tried using:
> >
> >
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file
> >
> >That may well do all/most of what you want.
>
> I have tried that now. This way I get the whole response as an xml file.
> The
> actual data which was returned from the SOAP method is between the follwing
> tags:
>
> <convertReturn xsi:type="xsd:base64Binary">
> GFydHhyZWYKMzUzMDkKJSVFT0YK</convertReturn>
>
> I can write another Java function which could read the data transform it
> from Base64 to byte[] and write the actual result file to disk, but I just
> hoped it goes more simplier. I hoped in a post-processor I can somehow get
> that Base64 data transform it to byte[] and write the file to disk.
>
>
> sebb-2-2 wrote:
> >
> > On 26/04/2010, thorr09 <bv...@gmail.com> wrote:
> >>
> >>  Hi guys!
> >>  Sorry for not greeting you on friday...my mistake.
> >>  Thanks for the reply...I have another question. I want to write a
> >> Beanshell
> >>  post processor now which will write the binary result data of a SOAP
> >> call to
> >>  a file. How do I have access to that data in the BeanShell script? The
> >> data
> >>  should be present in the response, how could I read it from there
> maybe?
> >>  Thanks in advance,
> >>  Cheers,
> >>
> >
> > Have you tried using:
> >
> >
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file
> >
> > That may well do all/most of what you want.
> >
> >>
> >>  TincaTibo wrote:
> >>  >
> >>  > Hello (Don't you know the netiquette?)
> >>  >
> >>  > Exactly, you can use Beanshell, as Beanshell can be considered as
> >>  > scripting
> >>  > in Java. So you can call whatever Java you wrote, create or modify
> >> JMeter
> >>  > Variables in the script and then use it wherever you want.
> >>  > See
> >>  >
> >>
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_Sampler
> >>  > And *for full details on using BeanShell, please see the BeanShell
> >>  > web-site
> >>  > at http://www.beanshell.org/*
> >>  >
> >>  > Regards,
> >>  > Tibo
> >>  >
> >>  > On Fri, Apr 23, 2010 at 13:22, thorr09 <bv...@gmail.com> wrote:
> >>  >
> >>  >>
> >>  >> How is it possible to run Java code and write the returned value in
> >> the
> >>  >> request in a Sampler? Does BeanShell support Java code, or can it
> >> call
> >>  >> somehow java code?
> >>  >> --
> >>  >> View this message in context:
> >>  >>
> >>
> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28340073.html
> >>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>  >>
> >>  >>
> >>  >>
> ---------------------------------------------------------------------
> >>  >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >>  >> For additional commands, e-mail:
> jmeter-user-help@jakarta.apache.org
> >>  >>
> >>  >>
> >>  >
> >>  >
> >>
> >>
> >> --
> >>  View this message in context:
> >>
> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28362934.html
> >>
> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >>
> >>  ---------------------------------------------------------------------
> >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28364086.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: Jmeter preprocessors, Java code...

Posted by thorr09 <bv...@gmail.com>.
Thanks for the reply

>Have you tried using:
>
>http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file
>
>That may well do all/most of what you want.

I have tried that now. This way I get the whole response as an xml file. The
actual data which was returned from the SOAP method is between the follwing
tags:

<convertReturn xsi:type="xsd:base64Binary">
GFydHhyZWYKMzUzMDkKJSVFT0YK</convertReturn>

I can write another Java function which could read the data transform it
from Base64 to byte[] and write the actual result file to disk, but I just
hoped it goes more simplier. I hoped in a post-processor I can somehow get
that Base64 data transform it to byte[] and write the file to disk.


sebb-2-2 wrote:
> 
> On 26/04/2010, thorr09 <bv...@gmail.com> wrote:
>>
>>  Hi guys!
>>  Sorry for not greeting you on friday...my mistake.
>>  Thanks for the reply...I have another question. I want to write a
>> Beanshell
>>  post processor now which will write the binary result data of a SOAP
>> call to
>>  a file. How do I have access to that data in the BeanShell script? The
>> data
>>  should be present in the response, how could I read it from there maybe?
>>  Thanks in advance,
>>  Cheers,
>>
> 
> Have you tried using:
> 
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file
> 
> That may well do all/most of what you want.
> 
>>
>>  TincaTibo wrote:
>>  >
>>  > Hello (Don't you know the netiquette?)
>>  >
>>  > Exactly, you can use Beanshell, as Beanshell can be considered as
>>  > scripting
>>  > in Java. So you can call whatever Java you wrote, create or modify
>> JMeter
>>  > Variables in the script and then use it wherever you want.
>>  > See
>>  >
>> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_Sampler
>>  > And *for full details on using BeanShell, please see the BeanShell
>>  > web-site
>>  > at http://www.beanshell.org/*
>>  >
>>  > Regards,
>>  > Tibo
>>  >
>>  > On Fri, Apr 23, 2010 at 13:22, thorr09 <bv...@gmail.com> wrote:
>>  >
>>  >>
>>  >> How is it possible to run Java code and write the returned value in
>> the
>>  >> request in a Sampler? Does BeanShell support Java code, or can it
>> call
>>  >> somehow java code?
>>  >> --
>>  >> View this message in context:
>>  >>
>> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28340073.html
>>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>>  >>
>>  >>
>>  >> ---------------------------------------------------------------------
>>  >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>  >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>  >>
>>  >>
>>  >
>>  >
>>
>>
>> --
>>  View this message in context:
>> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28362934.html
>>
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28364086.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: Jmeter preprocessors, Java code...

Posted by sebb <se...@gmail.com>.
On 26/04/2010, thorr09 <bv...@gmail.com> wrote:
>
>  Hi guys!
>  Sorry for not greeting you on friday...my mistake.
>  Thanks for the reply...I have another question. I want to write a Beanshell
>  post processor now which will write the binary result data of a SOAP call to
>  a file. How do I have access to that data in the BeanShell script? The data
>  should be present in the response, how could I read it from there maybe?
>  Thanks in advance,
>  Cheers,
>

Have you tried using:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file

That may well do all/most of what you want.

>
>  TincaTibo wrote:
>  >
>  > Hello (Don't you know the netiquette?)
>  >
>  > Exactly, you can use Beanshell, as Beanshell can be considered as
>  > scripting
>  > in Java. So you can call whatever Java you wrote, create or modify JMeter
>  > Variables in the script and then use it wherever you want.
>  > See
>  > http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_Sampler
>  > And *for full details on using BeanShell, please see the BeanShell
>  > web-site
>  > at http://www.beanshell.org/*
>  >
>  > Regards,
>  > Tibo
>  >
>  > On Fri, Apr 23, 2010 at 13:22, thorr09 <bv...@gmail.com> wrote:
>  >
>  >>
>  >> How is it possible to run Java code and write the returned value in the
>  >> request in a Sampler? Does BeanShell support Java code, or can it call
>  >> somehow java code?
>  >> --
>  >> View this message in context:
>  >> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28340073.html
>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>
>  >>
>  >
>  >
>
>
> --
>  View this message in context: http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28362934.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

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


Re: Jmeter preprocessors, Java code...

Posted by thorr09 <bv...@gmail.com>.
Hi guys!
Sorry for not greeting you on friday...my mistake.
Thanks for the reply...I have another question. I want to write a Beanshell
post processor now which will write the binary result data of a SOAP call to
a file. How do I have access to that data in the BeanShell script? The data
should be present in the response, how could I read it from there maybe?
Thanks in advance,
Cheers,


TincaTibo wrote:
> 
> Hello (Don't you know the netiquette?)
> 
> Exactly, you can use Beanshell, as Beanshell can be considered as
> scripting
> in Java. So you can call whatever Java you wrote, create or modify JMeter
> Variables in the script and then use it wherever you want.
> See
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_Sampler
> And *for full details on using BeanShell, please see the BeanShell
> web-site
> at http://www.beanshell.org/*
> 
> Regards,
> Tibo
> 
> On Fri, Apr 23, 2010 at 13:22, thorr09 <bv...@gmail.com> wrote:
> 
>>
>> How is it possible to run Java code and write the returned value in the
>> request in a Sampler? Does BeanShell support Java code, or can it call
>> somehow java code?
>> --
>> View this message in context:
>> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28340073.html
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28362934.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: Jmeter preprocessors, Java code...

Posted by TincaTibo <Ti...@gmail.com>.
Hello (Don't you know the netiquette?)

Exactly, you can use Beanshell, as Beanshell can be considered as scripting
in Java. So you can call whatever Java you wrote, create or modify JMeter
Variables in the script and then use it wherever you want.
See
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_Sampler
And *for full details on using BeanShell, please see the BeanShell web-site
at http://www.beanshell.org/*

Regards,
Tibo

On Fri, Apr 23, 2010 at 13:22, thorr09 <bv...@gmail.com> wrote:

>
> How is it possible to run Java code and write the returned value in the
> request in a Sampler? Does BeanShell support Java code, or can it call
> somehow java code?
> --
> View this message in context:
> http://old.nabble.com/Jmeter-preprocessors%2C-Java-code...-tp28340073p28340073.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>