Friday, July 26, 2013

SOAP UI Groovy Script : Random Number generator

********************************************
variable = Match.random()
log.info variable

********************************************
context.variable = Match.random()
log.info ${variable} // Syntax to read data into a request node

context.variable = Match.random() * 100
log.info ${variable} // Syntax to read data into a request node

<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
   <SOAP-ENV:Body>
      <m:OrderItem xmlns:m="Some-URI">
      <ItemNumber>${variable}</ItemNumber>
     </m:OrderItem>
   </SOAP-ENV:Body>  
</SOAP-ENV:Envelope>
********************************************
context.variable = Match.random() * 1000
log.info ${variable} // Syntax to read data into a request node

<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
   <SOAP-ENV:Body>
      <m:OrderItem xmlns:m="Some-URI">
      <ItemNumber>${variable}</ItemNumber>
     </m:OrderItem>
   </SOAP-ENV:Body>  
</SOAP-ENV:Envelope>
*********************************************
context.variable = Match.random(Match.random() * 1000)
log.info ${variable} // Syntax to read data into a request node

<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
   <SOAP-ENV:Body>
      <m:OrderItem xmlns:m="Some-URI">
      <ItemNumber>${variable}</ItemNumber>
     </m:OrderItem>
   </SOAP-ENV:Body>  
</SOAP-ENV:Envelope>
******************************************** 

No comments:

Post a Comment