Accessing file resources in SoapUI Mock Service Deployed in tomcat

后端 未结 1 868
执念已碎
执念已碎 2021-01-05 04:45

Problem in short : Accessing local file in SCRIPT Dispatcher with respect to project path i.e., def file = new File(groo

相关标签:
1条回答
  • 2021-01-05 05:42

    The main issue being : groovyUtils.projectPath is working only for first use case, and getting nothing for second use case.

    After lot of trial & errors and search on the net, found a hint in one of the samples and the following approach working to be able to access the local file resource both below use cases as mentioned in the question.

    • running as mock service from soapUI itself
    • deployed as war in remote tomcat

    So changed the code (script of mock dispatcher)
    from:

       def file = new File(groovyUtils.projectPath+"/${responseFileName}.xml")
    

    to:

       def projectPath = new File(mockOperation.mockService.project.path).parent
       def file = new File(projectPath.+"/${responseFileName}.xml")
    

    Note: file(resource) must be available in the same location where soapui project file is present on the disk i.e., after creatin .war file, update .war file and make sure the required file is placed under WEB-INF/soapui as that where soapui's project xml is available.

    0 讨论(0)
提交回复
热议问题