Forum Discussion

aacsoares's avatar
aacsoares
New Contributor
12 years ago

Mock Service - WebService returns HTTP 202 without Body

Hi everyone,

I'm using the free version of SoapUI for mocking some returns of web-services from the client. One of those web-services has no response, returning to me the HTTP 202 only. The mockservices is deployed on TOMCAT using the option "deploy as WAR" of the project. The problem is that, when I execute this web-service that has no response, the WebUI application stops working. The error is like below:


java.lang.NullPointerException
com.eviware.soapui.mockaswar.MockAsWarServlet.printMaster(MockAsWarServlet.java:422)
com.eviware.soapui.mockaswar.MockAsWarServlet$MockServletSoapUICore.dispatchRequest(MockAsWarServlet.java:297)
com.eviware.soapui.mockaswar.MockAsWarServlet.service(MockAsWarServlet.java:190)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


This is a problem to my project because we need to view the request/response log. Does anyone had this kind of problem in this situation? I really need some help here. hust to remind, there is no response configured on the XSD. The return is only a HTTP 202. I think that, since this web-service is out of pattern, WebUI tries to read a response and found nothing, throwing the NullPointer. Maybe someone could provide a groove script to solve this kind of problem.

Thanks in advance.

5 Replies

  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    hi, can you tell us which SoapUI version you are using please?
    Did you reproduce the error when running the mock directly with the SoapUI Gui? I would like to know if the problem comes from the war or is a SoapUI internal issue
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    Forget my previsous post, the error is related to the servlet. As you suggest, the mockOperation is null in your case so there is a NullPointerException
    see https://github.com/SmartBear/soapui/blo ... .java#L422
    line 422: out.print( "<td>" + result.getMockOperation().getName() + "</td>" );
    Error could also occurs on line 425

    I guess there is something missing in the implementation because on line 423, there is a null check for the MockResponse

    Anyway, you have the following solution: patch the servlet to add null check. Can you manage it by yourself?

    Last question for my understanding: how did you configure the mock to generate the http header only response? with groovy script? could you share this information please?
    Thanks
  • aacsoares's avatar
    aacsoares
    New Contributor
    Hi thanks, for the return.

    I used a groovy script to generate the 202 situation with no body. We verified with the client that his implementation did not return a body for response and an HTTP 202. I saw this because the XSD did not contains the response definition. The script to simulate is like below:


    if ( mockRequest.method == "POST" )
    {
    def mockResponse = mockRequest.getHttpResponse()
    mockResponse.setStatus(202, "Accepted")
    return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest)
    }


    Unfortunately I do not know how to add null check to the servlet. This is my first "advance" iteration to SOAPUI. If you have any example or tutorial I can handle myself after.

    Thanks in advance.
  • aacsoares's avatar
    aacsoares
    New Contributor
    Yes, very much. I will try here and return with the answer.

    Thanks.