Forum Discussion

verveja's avatar
verveja
New Contributor
9 years ago

MockService : Deploy As War : no WebUI

Using SoapUI 5.2.1 (open source) I am able to run and use a very simple REST MockService.

 

Using the "Deploy As War" feature, with the "WebUI (Check to enable WebUI)" option selected, I am able to create a WAR file.

 

The documentation says, after deploying the WAR file :
"... open a web browser and point it to the root of the deployed war we get the following interface ..."

 

But, all I see is a blank page.

 

Any suggestions for what I might be doing wrong, or what I should do, to get the WebUI interface?

 

I tried this using "GlassFish Server Open Source Edition 4.1.1 (build 1)" and "Jetty 9.3.8.v20160314", both gave a blank page (while properly responding to the mock actions/resources).

 

This is de SoapUI project XML (also attached as "review-as-war-enable-webui-project-soapui-project.xml") :

 

<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project id="b36268c5-23df-41c4-98be-31c2b192710d" activeEnvironment="Default" name="review-as-war-enable-webui-project" resourceRoot="" soapui-version="5.2.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config">
  <con:settings/>
  <con:restMockService id="eb9515c2-7d32-4130-92fe-7c516f20c03b" port="8080" path="/" host="6G1VJ72" name="some REST MockService">
    <con:settings/>
    <con:properties/>
    <con:restMockAction name="/resource1" method="GET" resourcePath="/resource1" id="70e7cad1-a37d-4797-a5e8-e52b5c7dd70d">
      <con:settings/>
      <con:defaultResponse>R1Response</con:defaultResponse>
      <con:dispatchStyle>SEQUENCE</con:dispatchStyle>
      <con:dispatchPath/>
      <con:response name="R1Response" id="a9e50ff6-aacd-469e-b740-328b755bee54" httpResponseStatus="200" mediaType="application/json">
        <con:settings/>
        <con:responseContent>{"theresponse":"for resource1"}</con:responseContent>
      </con:response>
    </con:restMockAction>
    <con:restMockAction name="/resource2" method="GET" resourcePath="/resource2" id="206f014f-71c6-48de-bcf0-313500e024b2">
      <con:settings/>
      <con:defaultResponse>R2Response</con:defaultResponse>
      <con:dispatchStyle>SEQUENCE</con:dispatchStyle>
      <con:dispatchPath/>
      <con:response name="R2Response" id="f88f55e2-2552-4704-967d-2e0ae5ea1b34" httpResponseStatus="200" mediaType="application/json">
        <con:settings/>
        <con:responseContent>{"theresponse":"for resource2"}</con:responseContent>
      </con:response>
    </con:restMockAction>
  </con:restMockService>
  <con:properties/>
  <con:wssContainer/>
  <con:oAuth2ProfileContainer/>
  <con:sensitiveInformation/>
</con:soapui-project>

(Some aspects of this XML code seem to be replaced by smileys in the preview, not a feature I would expect from a code section.)

 

Many thanks.

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    I think the deploy as war WebUI functionality is not implemented for REST Mocks, I think I remember seeing that last time I looked at the code (others please correct me if this has changed) - It definately worked for Soap Mocks last time I tried it.

     

    Regards,

    Rupert 

    • verveja's avatar
      verveja
      New Contributor

      Thanks for your reply Rupert.

       

      Good suggestion to check the source code.
      Do you have any specific pointers in the source code that suggest a WebUI is not implemented for a REST MockService?

       

      To me it looks like some exceptions should be made for some specific URIs used by the WebUI, for example like this :
      (in https://github.com/SmartBear/soapui/blob/next/soapui/src/main/java/com/eviware/soapui/mockaswar/MockAsWarServlet.java )

       

              private MockRunner getMatchedMockRunner(MockRunner[] mockRunners, String pathInfo) {
                  if (pathInfo != null
                      && (pathInfo.startsWith("/master") || pathInfo.startsWith("/detail") || pathInfo.startsWith("/log"))) {
                      return null;
                  }
                  // ...
              }

      Maybe these URIs could be prefixed (e.g. like "/soapui-master") to avoid potential conflicts with the resources in the REST MockService itself.

       

      Regards,
      Jan Vervecken

  • nmrao's avatar
    nmrao
    Champion Level 3
    I have only tried Deploy as war for soap mocking and deployed in tomcat.
    So, if it is possible for you, would you like to try it on tomcat instead of glassfish to confirm that it at least works on tomcat?
    • verveja's avatar
      verveja
      New Contributor

      Thanks for your reply Rao.

       

      If I deploy a WAR file for a SOAP MockService on Apache Tomcat 8.0.33 I get "HTTP Status 404" responses in each of three frames from the initial response.

       

      This is when I request "http://localhost:8080/soapwarcontextpath" without a slash at the end,
      resulting in URLs like "http://localhost:8080/master" being requested instead of "http://localhost:8080/soapwarcontextpath/master".

       

      If my initial request is to "http://localhost:8080/soapwarcontextpath/" with a slash at the end, there is no problem and I get the WebUI.

       

      If I deploy a WAR file for a SOAP MockService on "GlassFish Server Open Source Edition 4.1.1 (build 1)" an initial request for
      "http://localhost:8080/soapwarcontextpath" (without slash) seems to be automatically redirected to
      "http://localhost:8080/soapwarcontextpath/" (with slash) and the WebUI shows up.

       

      So, to be more robust, maybe this code in method MockAsWarServlet.printFrameset()

       

              out.print("<frame src=\"master\"/>");
              out.print("<frame name=\"detail\" src=\"detail\"/>");
              out.print("<frame src=\"log\"/>");

      could be replaced by something like this

       

              out.print("<frame src=\"" + request.getContextPath() + "/master\"/>");
              out.print("<frame name=\"detail\" src=\"" + request.getContextPath() + "/detail\"/>");
              out.print("<frame src=\"" + request.getContextPath() + "/log\"/>");

      Also, my initial question was about deploying a WAR for a REST MockService, which also has some specific issues (with the WebUI URIs) as mentioned in another reply in this topic.

       

      Regards,
      Jan Vervecken