Ask a Question

MockResponse dispatch script fails...

SaraCavelind
Contributor

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 6
SaraCavelind
Contributor

Re: MockResponse dispatch script fails...

Adding the project file with multipe mock services where I basically try to do the same in each...Off for two weeks vaccation now, hopefully someone had the oppurtunity to have a look meanwhile 🙂

Re: MockResponse dispatch script fails...

Hi!

We're not getting the null pointer when we're calling http://localhost:8088/mockgetPolicyListCivilBinding from the "from anders" request.
How did you call the MockService?
Are you running mockgetPolicyListCivilBinding in isolation or are you running multiple MockServices simultaneously?

--
Regards

Erik
SmartBear Sweden


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
SaraCavelind
Contributor

Re: MockResponse dispatch script fails...

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.

Re: MockResponse dispatch script fails...

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


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
SaraCavelind
Contributor

Re: MockResponse dispatch script fails...

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!

Re: MockResponse dispatch script fails...

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


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: