Forum Discussion

grussell's avatar
grussell
Contributor
15 years ago

Mock throws error on an empty body (v3.6.1)

Hi

I have a "get" message which simply has a null body tag which is used to get some information, I am trying to mock this so I set up a mock soap message, left the dispatch to SEQUENCE and sent in the message but I get a soapfault:
Missing operation for soapAction [GetStuff] and body element [null] with SOAP Version [SOAP 1.1]

This seems similar to viewtopic.php?t=5648 but instead of handling the whole thing myself in the OnRequest Script I would just like the mock to work for a null body as it would for anything else.

Thanks

5 Replies

  • Also similar to viewtopic.php?f=5&t=4356 how can I return a defined soap message from the "OnRequest Script" I've tried to create a mockResult and setResponseContent but I get "dispatch error; missing response".

    Thanks
  • I hope someone can tell me what exactly I'm doing wrong here but this is what I have in the OnRequest Script:
    import com.eviware.soapui.impl.wsdl.mock.WsdlMockResult

    WsdlMockResult mockResult = new WsdlMockResult( mockRequest )
    String s = "<some xml I would like to return>"
    mockResult.setResponseContent(s)

    return mockResult
  • Hi,

    Writing the response manually can be done using the HttpResponse object of the MockRequest.
    You'll need to modify your script slightly:


    import com.eviware.soapui.impl.wsdl.mock.WsdlMockResult

    WsdlMockResult mockResult = new WsdlMockResult( mockRequest )
    String s = "<some xml I would like to return>"
    mockRequest.httpResponse.writer << s
    mockRequest.httpResponse.status = 200

    return mockResult


    Regards,
    Dain
    SmartBear Sweden