Forum Discussion
Hello Nmrao,
Sorry for the delays – due to a misunderstanding I didn't see your question until yesterday. Unfortunately there's no way to get to the servlet itself in the code. The Virts (mock services) don't have any reference, direct or indirect, back to it. Frankly this scenario never occurred to us, since the web.xml is hardcoded and packaged inside soapui.jar. Are you creating a custom web.xml or something?
The Groovy snippet below will read the parameter value from the embedded web.xml and store it in the scriptsDirectory variable. Of course, if you're reading the web.xml in some other way, you need to replace the SoapUI.class.getResourceAsStream(...) with a FileInputStream etc.
Hope this helps!
Manne Fagerlind, Ready! API/SoapUI developer
import com.eviware.soapui.SoapUI
def webXml = new XmlSlurper().parse(SoapUI.class.getResourceAsStream("/com/eviware/soapui/resources/mockaswar/web.xml"))
def scriptsParameter = webXml.servlet["init-param"].find { param ->
param['param-name'] == 'scripts'
}
def scriptsDirectory = scriptsParameter['param-value']