Ask a Question

Mock REST Services War dynamic url parameters

Occasional Contributor

Mock REST Services War dynamic url parameters

When we create a war for the Mock REST service and deploy in tomcat, i am not able to pass the dynamic values in the url path for a GET request. Tomcat ignores the url path and throws a default error message.

Say, http://localhost:8080/mockService/Test/{param0}/data is working fine within soapui and i am able to pass dynamic values to param0 in soapui.
When i deploy this service as war in tomcat, it is not recognizing values set for param0 in the url and the response is default soap error message. Tomcat treats this "http://localhost:8080/mockService/Test/{param0}/data" as complete url and renders the response for matching path.

I don't have a choice to change the url pattern as the client code will get affected. Is there a way to handle this type of url for REST mock services or any documentation to check this?
Occasional Contributor

We had to override the method dispatchRequest (req, res) in MockAsWarServlet to accept the additional parameters in url for REST requests.
Occasional Contributor

Hello gopiharan79,
i have the same problem.
Can you please post your code for the MockAsWarServlet?
Occasional Contributor

We replaced the line - if( pathInfo.equals( mockRunner.getMockService().getPath() ) )
with if( pathInfo.startsWith( mockRunner.getMockService().getPath() ) ) in dispatchRequest method to accept url parameters.
Super Contributor

Seems to be very closed to viewtopic.php?f=2&t=15313, no?
Champion Level 3

@azan00, do you have the content of the link as it is no more reachable.


I have the same issue. How did you override it?

Showing results for 
Search instead for 
Did you mean: