Hi I am using SoapUI for testing web services. I need to create a customer record with email address and password. Create customer record service contains emailid and password, when I click the run(submit request) button in create customer record in SoapUI, I should get the emailid appended with current time of creation and any password.
How to do this with groovy?
There are two common cases of inserting dynamic dateTime value in soapUI using groovy:
Insert formatted timestamp value. Use SimpleDateFormat in this case:
${=new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date())}
Format timestamp as xsd:dateTime value. Use DatatypeFactory to create instance of newXMLGregorianCalendar:
${=javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(GregorianCalendar.getInstance())}
I think that the first case works for you. Insert the code in your request and adjust timestamp format for your needs. BTW, it also works in responses for mock servers.