Apoorva6
8 years agoFrequent Contributor
Need help in groovy script to fetch proper response.
I need help in below issue. I have 2 attributes in request orderComponentId and orderDataType. orderDataType can take 2 values (TTTN and PORT) and orderComponentId can take any value. I have 2 p...
- 8 years ago
Can you try below script ? Note that I could not test before providing as I do not have artifacts.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def holder = groovyUtils.getXmlHolder(mockRequest.requestContent) def soNumber = holder.getNodeValue("//*:InquireEnterpriseTNOrderDataRequest/*:orderComponentId") def orderType = holder.getNodeValue("//*:InquireEnterpriseTNOrderDataRequest/*:orderDataType") def prefix = "${groovyUtils.projectPath}/MOCK/CSI/IETN/" def getPrefix = { orderType == 'PORT' ? ("${prefix}PORTEDTN/" as String) : prefix } def getFileName = { def fileName = "${getPrefix()}${soNumber}.xml" as String def file = new File(fileName) file.exists() ? fileName : ("${getPrefix()}soapFault.xml" as String) } def getResponseContent = { new File(getFileName()).text } context.content = getResponseContent() log.info "Response content is set to : ${context.content}"