Forum Discussion

Knowledge's avatar
Knowledge
Contributor
9 years ago
Solved

Validations on MockService

Hi,

 

I have the following testing structure, and I would appreciate some help with how to validate mock services incoming messages on SoapUI:

 

I am sending a SOAP message from soapui to simulate the client, it goes to my server which sends a 200OK response back to the soapui. Then, my server sends an action to a different server, which sends it back to a different client, which is a listener only, which I simulate using a mock service in soapui.

I have an automation tool that launches soapui from the command line, and then needs to validate the results(by looking at the log printed by soapui).

The problem I have is how to run validations on the incoming request to the soapui mock service? Since the soapui generic validations/assertions are made on the 200OK response.

I thought about maybe writing a script that will export the incoming message to a log file. Is that possible?

If anyone has a an idea that would be very helpful.

 

Thanks in advance.

  • Hi,

    When you do:

    def file1 = new File('/temp/groovy1.txt')
    file1 << mockRequest.getRequestContent()

    That should append to the file, the << is the same as .append()

     

    Did you try making multiple requests to your mock? The file should contain all of them.

     

    If you do this, I don't think you get a line break inserted - if you want one its easy to add, see

    http://stackoverflow.com/questions/23410973/groovy-how-to-append-text-in-file-new-line

     

    Alternatively, you could consider creating one file per request or unique request - one exmple of this involves extracting some property of the request and appending it to the file name e.g.

     

    def requestXMLHolder = new com.eviware.soapui.support.XmlHolder(mockRequest.requestContent)
    requestXMLHolder.declareNamespace("inv","http://www.test.samples/schema/invoice")
    def requestInvoiceNo=requestXMLHolder.getNodeValue("//inv:getInvoice[1]/inv:invoiceNo[1]")
    
    def file1 = new File('/temp/groovy1'+requestInvoiceNo+'.txt')
    
    file1 << mockRequest.getRequestContent()

    Regards,

    Rupert

     

     

     

     

13 Replies