Forum Discussion
Sure, you can just use Groovy Strings to do that:
String port = "8089" def get = new URL("http://localhost:${port}/budg/inforeuro/api/public/monthly-rates").openConnection()
As for where to set the value for 'port', why not read it directly from the MockService itself?
String port = context.expand('${=project.getRestMockServiceByName("MockService").port}') def get = new URL("http://localhost:${port}/budg/inforeuro/api/public/monthly-rates").openConnection()
I think that I answer my question when I was writing it. I have the same script, the one that builds the MockService URL and returns the response, in two places. In MockService level and in Get Currencies level (into the MockService). So maybe, the scripts were running one by one, so the first time, the port was taken. So I was receiving a connection refuse exception.
I have retain the script in the Get Currencies level, I hope this is the correct level to have it. And now I am able, using command line to run the service in any port and build dynamically the URL in the MockProxy using the solution you gave me.
Thank you for helping, it was the first time I am writing to such a community, I should have done it earlier.
Related Content
- 12 years ago
- 10 months ago
Recent Discussions
- 2 days ago
- 2 days ago