cancel
Showing results for 
Search instead for 
Did you mean: 

I want to create a REST mock service with path parameters.

Highlighted
New Member

I want to create a REST mock service with path parameters.

I want to create a REST mock service with path parameters. 

Something like http://localhost:8080/edit/{id}

 

Is this possible with Soap UI?

 

3 REPLIES 3
Highlighted
Valued Contributor

Re: I want to create a REST mock service with path parameters.

Hi,

 

If you mean can you set up a mock with a resource e.g. /quote/task/{id} so that you can do GET requests like /quote/task/12345. Then I would set the mock up like:

 

Screen Shot 2015-10-02 at 13.27.16.png

And then to get the id parameter value, use some Groovy script in the Dispatch(Script) e.g.

 

def id = mockRequest.getPath().split("/")[-1]

log.info "id: " + id

 

Then you can use the id to selectively return responses:

 

if (id=="12345") return "Quote12345Response"

 

Or use it for other tasks or include it in the response etc.

 

Is this what you mean?

Cheers,

Rupert

 

Author of SoapUI Cookbook
Highlighted
New Contributor

Re: I want to create a REST mock service with path parameters.

This does not work when deployed as war!

Highlighted
New Contributor

Re: I want to create a REST mock service with path parameters.

Please try the below line:

def requestPath = mockRequest.getPath();

def reqPathLastVar = requestPath.substring(requestPath.lastIndexOf("/") + 1);

 

the above lines worked fine even if if you deploy the war file on server.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors