Forum Discussion

aedahh's avatar
aedahh
New Contributor
7 years ago

Mock REST, how to save binary file attachment from client request to file system?

Hello,

I have SOAPUI running mock REST and returing some json resonse, this part is working okay.

I would like to save the binary file attachment from the client's REST request, which is coming from another client, not SOAPUI test request, to SOAPUI server side during processing of the client's request. Where do I start with this? Thanks 

  • In your mock request definition lookup the Script tab, see also here.

    THen adjust to your needs, here I used a XML request to check if it is working.

     

     

    def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
    
    new File('c:/foo.txt').withOutputStream { 
    	it.write holder.getNodeValue("//<xpath>").getBytes()
    }