Forum Discussion

soapman's avatar
soapman
Occasional Contributor
16 years ago

"mockRequest.requestContent" in onRequest script returns nothing

I have the following simple code in the onRequest script of the mock service:

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)

When I run the test case, it complains that mockRequest is comming back as null. However I can manually see the request message in the MockService UI.

I am testing locally on my PC, so the endpoint for my testcase is, for example, http://mypc:8080/

Any ideas? This is driving me crazy!

4 Replies

  • Hi,

    I've added this to a simple mockservice and it works ok.. can you elaborate on your specific setup? or any error message? Or maybe share your project so I can try to reproduce?

    Also be sure to use the latest build!

    regards,

    /Ole
    eviware.com
  • soapman's avatar
    soapman
    Occasional Contributor
    I'm using soapUI Pro 3.5.1 Build dist-97-2010-04-12, Build Date 2010/04/12 09:51. Please see the attached screenshot. This is happening in the OnRequest script tab.
  • Hi!

    ok.. it looks like you get this error when you press the green arrow, which is fine since there at that time is no mockRequest available.. it will be when an actual request is processed by the MockService.. have you tried that?

    regards!

    /Ole
    eviware.com
  • Hiya

    I too found this infuriating but I've found that you can still see if anything is being passed into the variables by using the script logging window and outputting the value you are extracting into the variable by using :
                            log.info ReqNodeVal

    where ReqNodeVal is the populated variable

    when you use the green arrow button you get the NULL message pop up but the values still appear inthe script output