Ask a Question

Property Transfer Source: groovy script, Target: SOAP reques

Jack21Z
Occasional Contributor

Property Transfer Source: groovy script, Target: SOAP reques

Hi

I created a groovy script and i want to transfer directly my generated data/answer/result using TransferProperty to SOAP request without using Test Properties

thanks,
Jack
9 REPLIES 9
nmrao
Community Hero

Please see if the below link helps
http://www.soapui.org/Scripting-Propert ... properties


Regards,
Rao.
Jack21Z
Occasional Contributor

Hi,

Uhm, my test steps are the following:


GroovyScript --> script to generate data
PropertyTransfer --> Source: Groovy Script Target: SOAP Request
SOAP Request

My goal here is i'm not using any Test Properties of use case, test suite and others as possible


Regards,
Jack
nmrao
Community Hero

Sorry, please see this
http://www.soapui.org/Functional-Testin ... alues.html


Regards,
Rao.
Jack21Z
Occasional Contributor

nmrao wrote:
Sorry, please see this
http://www.soapui.org/Functional-Testin ... alues.html


Hi Rao,

You know any samples that the TransferProperty Source: Groovy Script?

Regards,
Jayson
nmrao
Community Hero

Hey,

In the first link provided has the sample how to set a value to a property and how to get the same. In this case, you would not require transfer property step at all. When property is used in the request, the value is automatically replaced when the request is sent.

For eg
There are two steps in a test case
Groovy
Test Step for soap request.

Groovy:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def timed = System.currentTimeMillis()
def myGeneratedValue = 'test_'+timed
testRunner.testCase.setPropertyValue("GENERATED_VALUE",myGeneratedValue)


Request may look:


<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header/>
<soapenv:Body>
<Reference>${#TestCase#GENERATED_VALUE}</Reference>
</soapenv:Body>
</soapenv:Envelope>



Note that you do not need to set any property value manually. At run time ${#TestCase#GENERATED_VALUE} will replaced with generated value run time automatically if test case is run or run groovy step first and then request step.
And smilarly you use properties at TestSuite, Project level as well. Hope this helps


Regards,
Rao.
Jack21Z
Occasional Contributor

Thanks Rao,

I figured it out!!!

groovy Scipt:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def timed = System.currentTimeMillis()
def myGeneratedValue = 'test_'+timed
return myGeneratedValue


PropertyTransfer Test Step:


Source: Groovy Script Property: result

Target: SOAP request Property: Request


Transfer the value from groovy -> soap request



SOAP request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header/>
<soapenv:Body>
<Reference>"value from groovy script"</Reference>
</soapenv:Body>
</soapenv:Envelope>


Regards,
Jack
nmrao
Community Hero

If i were you, do not use additional step - Property transfer which could be done groovy itself.


Regards,
Rao.

Hi Rao, 

 

I was actually stuck on the same issue as well, and you explained it beautifully. I have a question though... 

 

What if I want to create the property in a test suite or at a project level.. what changes to I need to make to the below script???

 

testRunner.testCase.setPropertyValue("GENERATED_VALUE",myGeneratedValue) 

 

 

 

Set property / its value at suite level

 

 

context.testCase.testSuite.setPropertyValue("GENERATED_VALUE",myGeneratedValue) 

project level:

 

 

context.testCase.testSuite.project.setPropertyValue("GENERATED_VALUE",myGeneratedValue) 

 



Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: