Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:07:57+00:00 2026-06-11T07:07:57+00:00

What I’ve Done I am using soapUI (3.6.1 Free version) mock services to serve

  • 0

What I’ve Done

I am using soapUI (3.6.1 Free version) mock services to serve up specific data to 2 client applications I am testing. With some simple Groovy script I’ve set up some mock operations to fetch responses from specific files based on the requests made by the client applications.

The static contents of the mock response is:

${responsefile}

The groovy in the operation dispatch scripting pane is:

def req = new XmlSlurper().parseText(mockRequest.requestContent)
if (req =~ "CategoryA")
{
    context.responsefile = new File("C:/soapProject/Test_Files/ID_List_CategoryA.xml").text
}
else
{
    context.responsefile = new File("C:/soapProject/Test_Files/ID_List_CategoryB.xml").text
}

In this example, when the client application issues a request to the mock service that contains the string CategoryA, the response returned by soapUI is the contents of file ID_List_CategoryA.xml

What I’m Trying To Achieve

This all works fine with the absolute paths in the groovy. Now I want to pull the whole collection of soapUI project file and external files into a package for easy re-deployment. From my reading about soapUI I hoped this would be as easy as setting the project Resource Root value to ${projectDir} and changing my paths to:

def req = new XmlSlurper().parseText(mockRequest.requestContent)
if (req =~ "CategoryA")
{
    context.responsefile = new File("Test_Files/ID_List_CategoryA.xml").text
}
else
{
    context.responsefile = new File("Test_Files/ID_List_CategoryB.xml").text
}

… keeping in mind that the soapUI project xml file resides in C:/soapProject/

What I’ve Tried So Far

So, that doesn’t work. I’ve tried variations of relative paths:

  • ./Test_Files/ID_List_CategoryA.xml
  • /Test_Files/ID_List_CategoryA.xml
  • Test_Files/ID_List_CategoryA.xml

One post indicated that soapUI might consider the project files parent directory as the root for the purposes of the relative path, so tried the following variations too:

  • ./soapProject/Test_Files/ID_List_CategoryA.xml
  • /soapProject/Test_Files/ID_List_CategoryA.xml
  • soapProject/Test_Files/ID_List_CategoryA.xml

When none of that worked I tried making use of the ${projectDir} property in the groovy script, but all such attempts failed with a “No such property: mockService for class: Script[n]” error. Admittefly, I was really fumbling around when trying to do that.

I tried using information from this post and others: How do I make soapUI attachment paths relative?

… without any luck. Replacing “test” with “mock,” (among other changes), in the solution code from that post resulted in more property errors, e.g.

testFile = new File(mockRunner.project.getPath())

.. led to…

No such property: mockRunner for class: Script3

What I Think I Need

The posts I’ve found related to this issue all focus on soapUI TestSuites. I really need a solution that is MockService centric or at least sheds some light on how it can be handled differently for MockServices as opposed to TestSuites.

Any help is greatly appreciated. Thanks. Mark.

The Solution – Provided by GargantuChet

The following includes the changes suggested by GargantuChet to solve the problem of trying to access the ${projectDir} property and enable the use of relative paths by defining a new projectDir object within the scope of the groovy script:

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def projectDir = groovyUtils.projectPath

def req = new XmlSlurper().parseText(mockRequest.requestContent)
if (req =~ "CategoryA")
{
    context.responsefile = new File(projectDir, "Test_Files/ID_List_CategoryA.xml").text
}
else
{
    context.responsefile = new File(projectDir, "Test_Files/ID_List_CategoryB.xml").text
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:07:59+00:00Added an answer on June 11, 2026 at 7:07 am

    I’m not familiar with Groovy, but I assume the File is a normal java.io.File instance.

    Relative paths are interpreted as being relative to the application’s current directory. Try something like the following to verify:

    def defaultPathBase = new File( "." ).getCanonicalPath()
    println "Current dir:" + defaultPathBase
    

    If this is the case here, then you may want to use the new File(String parent, String child) constructor, passing your resource directory as the first argument and the relative path as the second.

    For example:

    // hardcoded for demonstration purposes
    def pathbase = "/Users/chet"
    def content = new File(pathbase, "Desktop/sample.txt").text
    
    println content
    

    Here’s the result of executing the script:

    Chets-MacBook-Pro:Desktop chet$ groovy sample.groovy 
    This is a sample text file.
    
    It will be displayed by a Groovy script.
    Chets-MacBook-Pro:Desktop chet$ groovy sample.groovy 
    This is a sample text file.
    
    It will be displayed by a Groovy script.
    
    Chets-MacBook-Pro:Desktop chet$ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.