Ask a Question

messageExchange not recognised

surya123
Occasional Contributor

messageExchange not recognised

def holder = groovyUtils.getXmlHolder( messageExchange.responseContent );

When I try to execute this script , I get this pop up which says groovy.lang.MissingPropertyException:No such property:messageExchange for class: Script35

Please find the screenshot of the pop up attached.

I desperately need this to work ,where am I making a mistake?
6 REPLIES 6
wdowling
Occasional Contributor

I expect that the MessageExchange context is not available to you in the script. You will have to get the response from the request directly.

def holder = groovyUtils.getXmlHolder(testRunner.testCase.testSteps["XXXStepName"].testRequest.response.getContentAsXml());

should work.
surya123
Occasional Contributor

hi There,

Thanks a lot for the reply, your code does work, however, I would like to use the messageExchange for the same purpose.

Below is the code which I use :

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(messageExchange.responseContent)

I am creating context ,but still i get the same error.Do you know any possible reason for this.I am using soapui pro 3.5
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi!

exactly where in soapUI are you running this script?

regards!

/ole
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
surya123
Occasional Contributor

Hi

So sorry for the late reply on this.
I am running this in a test suite, in a groovy step.

Hi There,

 

I believe, 'messageExchange' is works only in Script Assertion. Your purpose can be solved by context.expand().

 

Thanks,

Chinmay

ryanz
Regular Visitor

The syntax is valid, assuming you are running it in Script Assertion. 

 

Moreover, please make sure your response is in xml format. Some api may sometimes return both json or xml if you does not specifically specify what you accept.

 

To make sure your response is accepting an xml, adding an Accept header in your request will help. 

cancel
Showing results for 
Search instead for 
Did you mean: