Looking for a little help with JMeter and something I thought would be straight-foward but instead now has me stumped and annoyed !
I am trying to get particular part of a Date into a SOAP/XML Sampler. First I tried the BeanShell approach...
BeanShell PreProcessor
I added a BeanShell PreProcessor to my SOAP/XML Sampler with the following
I then tried accessing the variable from my SOAP/XML request using ${currentDate} (stored in a User Defined Variables config element on the Thread Group).
Request:
<myTag>${currentDate} </myTag>
Response:
<myTag> </myTag>
No joy there... So I moved the Java to an external file and function (function.bsf) and tried:
BeanShell External File
Request:
<myTag>${__BeanShell(source("C:\function.bsf"))} </myTag>
Response:
<myTag> </myTag>
Again no joy!! So I moved onto to Javascript... But yet again nothing is returned.
Javascript
Request:
<myTag>${__javaScript("20120225".substring(4,4))} </myTag>
Response:
<myTag> </myTag>
Apologies for the weird formatting. As usual any help or guidance would be much appreciated!
I am trying to get particular part of a Date into a SOAP/XML Sampler. First I tried the BeanShell approach...
BeanShell PreProcessor
I added a BeanShell PreProcessor to my SOAP/XML Sampler with the following
Code:
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
String theDate = (String) dateFormat.format(Date);
vars.put ("currentDate", theDate);
Request:
<myTag>${currentDate} </myTag>
Response:
<myTag> </myTag>
No joy there... So I moved the Java to an external file and function (function.bsf) and tried:
BeanShell External File
Request:
<myTag>${__BeanShell(source("C:\function.bsf"))} </myTag>
Response:
<myTag> </myTag>
Again no joy!! So I moved onto to Javascript... But yet again nothing is returned.
Javascript
Request:
<myTag>${__javaScript("20120225".substring(4,4))} </myTag>
Response:
<myTag> </myTag>
Apologies for the weird formatting. As usual any help or guidance would be much appreciated!