Pages

Tuesday, March 11, 2014

Generating a random unique number in a SOAP UI request


In the request use,

${=System.currentTimeMillis() + ((int)(Math.random()*10000))}

example :  

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ode-apache-org:example:async:client">
<soapenv:Header/>
<soapenv:Body>
<urn:ClientRequest>
<urn:id>${=java.util.UUID.randomUUID()}</urn:id>
<urn:input>Hello Wolrd</urn:input>
</urn:ClientRequest>
</soapenv:Body>
</soapenv:Envelope>
Note : Here I am generating this number by adding currant milliseconds as a prefix. So this will generate almost unique number.


Update: 20th June 2014. 

Another simple way to do this. 

${=java.util.UUID.randomUUID()}

No comments:

Post a Comment