Forum Discussion

Char's avatar
Char
New Contributor
16 years ago

Running MockService as Servlet

Hello,

i want to run a soapui mockservice as HTTP-Servlet, just as described here:
http://www.eviware.com/blogs/oleblog/?p=110


My code:


   public void init() throws ServletException
   {
      super.init();
      try
      {          
         project = new WsdlProject("D:/otherWorkspaces/CurrencyConvertor-soapui-project.xml");

         mockService = project.getMockServiceByName(getInitParameter("mockService"));
         mockRunner = mockService.start();
      }
      catch (Exception ex)
      {
                    ...
      }
   }

   protected void service(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
   {
   try
      {
         MockResult result = mockRunner.dispatchRequest(request, response);
      }
      catch (DispatchException ex)
      {
                   ....
      }
   }



I deploy the servlet with the soapui libraries into a JBoss 4.2.3.

When i call it, i see that the MockService is started with a different Url:

[JettyMockEngine] Started mockService [CurrencyMockService] on port [8088] at path [/mockCurrencyConvertorSoap]


Now i would expect that the dispatchRequest-method would forward my HTTP-request to this endpoint. Then the mock would fill the MockResult as i have configurated the MockResponse in SoapUI before.

But why is result == NULL ?

Edit: Additional logs:


17:05:58,135 INFO  [STDOUT] mockRunner.getLocalMockServiceEndpoint(): http://WEP05720:8088/mockCurrencyConvertorSoap
17:05:58,135 INFO  [STDOUT] mockRunner.getMockResultCount(): 0
17:05:58,135 INFO  [STDOUT] mockRunner.getMockContext().toString(): {}
17:05:58,135 INFO  [STDOUT] MockContext is empty.
17:05:58,135 INFO  [STDOUT] mockRunner.getMockService().getName(): CurrencyMockService
17:05:58,135 INFO  [STDOUT] mockRunner.getOverviewUrl(): /mockCurrencyConvertorSoap?WSDL



Moreover, i can use the eclipse WebServiceExplorer to send a request to the MockEndpoint (not the JBoss-Servlet, but the published one by the servlet)
but i will always get a HTTP 403 response...

Thanks in advance!

1 Reply

  • Char's avatar
    Char
    New Contributor
    Problem solved.

    The correct response is included in HttpResponse response property and will be received when sending a valid POST-request.