Forum Discussion

Knowledge's avatar
Knowledge
Contributor
9 years ago

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 simulat...
  • rupert_anderson's avatar
    rupert_anderson
    9 years ago

    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