15 years ago
SoapUI Groovy Closures in Requests not working
I have a simple problem.
In a standard XML request, I want to dynamically build a couple of XML tags with Groovy.
What I want is output like this to be sent to the remote service:
I expect this groovy script to work, but it does not. There is nothing syntactically wrong with the groovy, but it causes an error in my SOAP UI Console:
The error is:
Wed Sep 22 13:39:30 CEST 2010:ERROR:Error evaluating script
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script83.groovy: 1: expecting '}', found '' @ line 1, column 66.
s>role$it</igRoles>"
^
org.codehaus.groovy.syntax.SyntaxException: expecting '}', found '' @ line 1, column 66.
Any ideas?
In a standard XML request, I want to dynamically build a couple of XML tags with Groovy.
What I want is output like this to be sent to the remote service:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://www.igb2bidp.org/userProvisioningSchemaTypes-v2.0/">
<soapenv:Header/>
<soapenv:Body>
<user:addUserType>
<idpUserId>some_id</idpUserId>
<igRoles>role1</igRoles>
<igRoles>role2</igRoles>
<igRoles>role3</igRoles>
</user:addUserType>
</soapenv:Body>
</soapenv:Envelope>
I expect this groovy script to work, but it does not. There is nothing syntactically wrong with the groovy, but it causes an error in my SOAP UI Console:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://www.igb2bidp.org/userProvisioningSchemaTypes-v2.0/">
<soapenv:Header/>
<soapenv:Body>
<user:addUserType>
<idpUserId>some_id</idpUserId>
${=(1..3).collect{ "<igRoles>role" + it + "</igRoles>" }.join('') }
</user:addUserType>
</soapenv:Body>
</soapenv:Envelope>
The error is:
Wed Sep 22 13:39:30 CEST 2010:ERROR:Error evaluating script
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script83.groovy: 1: expecting '}', found '' @ line 1, column 66.
s>role$it</igRoles>"
^
org.codehaus.groovy.syntax.SyntaxException: expecting '}', found '' @ line 1, column 66.
Any ideas?