Ask a Question

Mock REST Services War dynamic url parameters

gopiharan79
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?
6 REPLIES 6
gopiharan79
Occasional Contributor

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

Hello gopiharan79,
i have the same problem.
Can you please post your code for the MockAsWarServlet?
gopiharan79
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.
redfish4ktc2
Super Contributor

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

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


Regards,
Rao.

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

cancel
Showing results for 
Search instead for 
Did you mean: