Groovy in SOAP UI

accessing properties in SOAP request

Posted by: devakara on: September 16, 2008

Accessing variable values on the go while sending SOAP request to some service, might solve many problems at times. In SOAP UI, there are two ways to accomplish this

i) Using ‘Property Transfer’ step

ii) Using ‘Property Expansion’ accordingly wherever required. Here I am explaining this procedure fo accesing properties.

${#Scope#Property-name[#xpath-expression]}

${Property-name} refers to a Global Property
(example: ${UserName} to a global Property named “UserName”)

${#Project#Property-name}refers to a Project Property
(example: ${#Project#UserName} to a Property on Project level named “UserName”)

${#TestSuite#Property-name} refers to a TestSuite Property
(example: ${#TestSuite#UserName} to a Prop on TestSuite level named “UserName”)

${#TestCase#Property-name} refers to a TestCase Property
(example: ${#TestCase#UserName} to a Prop on TestCase level named “UserName”)

${TestStep-name#Property-name} refers to a property in a named TestStep.

We can refer to properties, like above, in SOAP request as well, wherever required.

For example, say under a TestCase, there are 3 steps:

a) Properties Step – ‘AppProperties’, which has a property ‘UserProp’ and some value for it.

 

b) SOAP Request – ‘AppRequest’, a valid SOAP request, which uses the above property value and is sent to some service.

c) Groovy Step – ‘ValidateResponse’, which validates the response from that service.

Now, as we know for which node the ‘UserProp’ value is to be used in SOAP Request, we can directly wite 

${AppProperties#UserProp}

between that node, as its value, as shown in below figure.

By this developer, will be able to access properties on the go, not only at TestCase level but also at TesStep, TestSuite and Project level.

 

(Please feel free to get back if u have any trouble…as I’m just a mail away…leave a comment otherwise)

1 Response to "accessing properties in SOAP request"

Hi,

I am trying to transfer an Id from one request to the next. The Id is generated with a generator, i.e. the vaule of the Id in Request 1 is “${DataGen#Id}”. In the second request I want to use the generated value of the Id, not the generating formula which will result in a new Id. Perhaps the answer is simple, but I could not find a way to achive this.

Thank for comments,
Arno

Leave a Reply