Forum Discussion

SaraCavelind's avatar
SaraCavelind
Contributor
12 years ago

MockResponse dispatch script fails...

Hi!
I'm writing a dispatch script in my mocked services to among other things call a request. The code I use is this:

def project = mockOperation.mockService.project
def request = project.interfaces["${BindingName}"].operations["${operationName}"].getRequestByName("${requestName}")
// set request from incoming
request.requestContent = mockRequest.requestContent

It appears as if the request object isn't set (I get a nullpointer when submitting further down)

request.submit( new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( request ), false )
// save response to context
requestContext.responseMessage = request.responseContentAsXml

What am I doing wrong??

6 Replies

  • Hi!
    I'm running all services in parallell (now in the first attemp somewhere like 15). The idea is to create a mock for ll our services. If the filename (a hash of the equest) is found on disk we will read that file and give that response. If it is not found we shall ask the sharp implementation for the response, save it to disk and then give it as response.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    I see...

    according to your project, you are running all MockServices on the same port. This should cause problems if you try to them all in parallel.
    Could you please elaborate on how you are handling this?
    Also, is it possible for you to create a smaller project which we could use to reproduce this?

    ---
    Regards
    Erik, SmartBear Sweden
  • Hi!
    It's just one application that will use this mock servers and on that aplication we run one automated GUI test at one given time, so I figure here will not be any collisions?

    So the situation right now:
    On Windows using the soapUI client; I can have multiple mockservices running on the same port; and executing a request to the mock will in fact go to the real system retrieve the data, save the file to disc, and show the result to the soapUI client. Perfect!

    Due to our environment we will execute the file using the mockservicerunner.sh, "nohup mockservicerunner.sh projectfil &" on AIX. When doing so I experience the same as If I run the file using mockservicerunner on windows: It appears I never get any answer from the backend system!

    Are there any limittaion to the mockservicerunner? Like not using the same ports as you suggested?

    def project = mockOperation.getMockService().getProject()
    def request = project.interfaces["getPersonBinding"].operations["getPersonOp"].getRequestByName("Request 1")

    // set request from incoming
    request.requestContent = mockRequest.requestContent

    // submit request asynchronously
    request.submit( new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( request ), false )

    // save response to context
    requestContext.responseMessage = request.responseContentAsXml

    def fileW = new File(fullFileName)
    fileW.createNewFile()
    fileW.setWritable(true, false)
    log.info "Skrivbar:"+fileW.canWrite()
    log.info "Innehåll"
    log.info requestContext.responseMessage -> empty!
    fileW.write(requestContext.responseMessage) -> Java Null pointer exception!
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    Sorry, I'm sure sure that I'm following you, but no, there should be no limitation when it comes to running several MockServices on diffrent ports using the mockservicerunner.sh.

    --
    Regards

    Erik
    SmartBear Sweden