Forum Discussion

gopiharan79's avatar
gopiharan79
Occasional Contributor
11 years ago

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

  • gopiharan79's avatar
    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's avatar
    CacyD
    Occasional Contributor
    Hello gopiharan79,
    i have the same problem.
    Can you please post your code for the MockAsWarServlet?
  • gopiharan79's avatar
    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.