Forum Discussion

erki's avatar
erki
Occasional Contributor
13 years ago

generic way to return ok response or fault in mock

I am writing a mockservice that consists of many different webservices and operations and i need a generic way to decide if i return ok or fault. All of the incoming request share the same header so i could read it in mockservice OnRequest script and set it into some variable that i could read later.
So in all my request a have:

<SOAP-ENV:Header>
<ns:someValue xsi:type="xsd:string">12345</ns:someValue >
.... skipped
</SOAP-ENV:Header>

So in OnRequest i could do something like:

def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
def arg = holder["//ns:someValue"]
if(arg == "12345){
// set some variable to True
}else{
// set that variable to False
}

And then in that actual mock operation i could use script dispatch strategy to read the value and decide what to return. Anyway. The problem is that i see no way to declare variables in mock. Not the mock level nor the operation level. It is my first mock so sorry if i am missing the obvious. Could anybody point me to the right direction?

EDIT: I could put the script to each operation, but since there is going to be a lot of operations i wouldn't want to copy-paste it so much in case i need to change it.