Ask a Question

Script Library - messageExchange

cdunne
Contributor

Script Library - messageExchange

Hi,

Is it possible to call the following from a method in the script library?

def response = messageExchange.responseContent
def soapVersion = messageExchange.operation.getInterface().soapVersion

I'm trying to externalise all my assertions for easier maintainence and I want to use the following to get the current response details in a testcase. I cannot get them to work in a preceeding groovy test step either. Any suggestions?

Cheers

Cormac
8 REPLIES 8
omatzura
Super Contributor

Hi Cormac,

you need to get hold of the messageExchange and pass it to your method in the script-library.. from what context are you calling it?

regards,

/Ole
eviware.com
cdunne
Contributor

Hi Ole,

Excuse my ignorance my Java/Groovy skills are rubbish but i'm not really sure what you mean by what context I call it?

Cormac
omatzura
Super Contributor

Hi Cormac,

sorry, I should have been clearer. Are you calling this method from a Groovy Script Step? Or a Script Assertion? Or from "somewhere else"?

regards!

/Ole
eviware.com
cdunne
Contributor

Hi Ole,

I'm calling the method from a script assertion (I tried to get it to work in a groovy script step also).

The idea is I have a number of scripted assertions as public methods in the external library. Some of the assertions require the Soap Version and Response to be passed as parameters. I was hoping that I could just create a couple of private methods which would retrieve this info for the request executed and I could call these methods as an alernative to passing the parameters. Hope this makes sense?

Cheers

Cormac
omatzura
Super Contributor

Hi Cormac,

sure, this makes great sense! You'll need to pass the messageExchange as an argument to the method, from there your method can extract the remquired properties.. ok?

regards!

/Ole
eviware.com
cdunne
Contributor

Thanks Ole,

Yeah this makes sense, this is what I have but I still get null returned.

import com.eviware.soapui.model.iface.*

private def getCurrentResponse(MessageExchange messageExchange){

return messageExchange.responseContent
}

Any suggestions?
cdunne
Contributor

Sorry,

I think I have this sorted now. I wasn't passing through the messageExchage arguement when I was calling the method. Should this not have thrown an error though?

Cheers

Cormac
omatzura
Super Contributor

Hi!

hmm.. maybe.. due to its "dynamic nature", Groovy tries to "make the best of things" when executing.. I guess you still had syntactically correct code..

regards!

/Ole
eviware.com
cancel
Showing results for 
Search instead for 
Did you mean: