2
votes

In SoapUI I have a groovy script to build an array with parameters I'd like to use in a SOAP response.

I have used the following command in groovy to set the Array in the context:

context.MyArray = MyArray

How do I access the array parameters within the SOAP tags?

I have tried <Tag>${MyArray[0]}</Tag> but it passes back an empty value.

Many thanks Peter

3
Instead groovy script should update the request content directly - Rao
I strongly disagree. Yes, you CAN. But I believe you shouldn't. Placing variables like this, makes it transparent, that the value is coming from somewhere else. That may not be the case, when manipulating the request directly, and may be a source of confusion when/if a testcase fails. - Steen
Rao - when you say 'groovy script should update the request content directly', do you mean build the complete Soap message as a string within the groovy script? - Peter

3 Answers

2
votes

Use the ${= some code } tag

Example:

<Tag>${= context.MyArray[0] }</Tag>

EDIT: As mentioned in the comments, it turns out this piece of code is a variable that SoapUI can understand directly. So you don't really need the "="

1
votes
 <YourTag> 
    ${context.MyArray[0]}
  </YourTag>
0
votes

What I have noticed is that it takes SoapUI a LONG time to generate a response when accessing variables from the context in the Soap response body - especially when using arrays.