Forum Discussion

shashankalst's avatar
shashankalst
New Contributor
6 years ago

Soap UI Mock service for Rest not working when deployed as war

0
I want to create SoapUI mock service for the endpoint: "/product/123456/details/". Here 123456 is path variable. I have created a soap ui mock service with path as "/product/" and in response I'm just giving back the path(Just for testing). When I run this mock service in SoapUI on port 8210, and hitting "http://localhost:8210/product/123456/details" works perfect. I get the below response.
"/product/123456/details"

But when I deploy this as mymockwar war in tomcat running on port 8080, If I hit "http://localhost:8080/mymockwar/product/123456/details/", Then I get the response as below.

<html>
    <head>
        <title>soapUI MockServices Log for project [MyNewMock]</title>
    </head>
    <body>
        <h3>Log is disabled.</h3>
    </body>
</html>

Now if I hit "http://localhost:8080/mymockwar/product/" it works and gives me the response as

"/product/"

How can I make this working with path variable when deployed in tomcat? Tomcat version: 7.0.22 SoapUI version: 4.5.2

Mock service xml below.

<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project xmlns:con="http://eviware.com/soapui/config" activeEnvironment="Default" name="MyNewMock" resourceRoot="" soapui-version="4.5.2" abortOnError="false" runType="SEQUENTIAL">
   <con:settings />
   <con:mockService port="8210" path="/product/" host="localhost" name="testSoapMock" bindToHostOnly="false" docroot="">
      <con:settings>
         <con:setting id="com.eviware.soapui.impl.wsdl.mock.WsdlMockService@require-soap-action">false</con:setting>
      </con:settings>
      <con:properties />
      <con:onRequestScript>def method = mockRequest.method;
def path = mockRequest.path;
log.info path
def response = mockRequest.getHttpResponse()
            response.setContentType("application/json")
            def writer = response.getWriter();
            writer.write(path)
            writer.close()</con:onRequestScript>
   </con:mockService>
   <con:properties />
   <con:wssContainer />
</con:soapui-project>
No RepliesBe the first to reply