Showing posts with label Groovy Scripts. Show all posts
Showing posts with label Groovy Scripts. Show all posts

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>
******************************************** 

Tuesday, July 23, 2013

SOAP UI : Groovy script to Store request files in local directory

SOAP UI : Groovy script to Store request files in local directory

//Path and File name to store request
def requestFile = "C://request.xml"
//Reading request content into an object
def request = context.expand( '${MyRequestName#Request}' )
//Accesing file created
def file = new File(requestFile)
//Writing request into the file created
file.write(request, "UTF-8")

Monday, July 22, 2013

SOAP UI : Groovy Script to store response files in local directory


//Path and File name to store response
def responseFile = "C://response.xml"

//Reading response content into an object
def response = context.expand( '${MyRequestName#Response}' )
//Accesing file created
def file = new File(responseFile)
//Writing response into the file created
file.write(response, "UTF-8")