Forum Discussion

Wave_Crest_Hold's avatar
Wave_Crest_Hold
Contributor
15 years ago

Groovy script for working with attachments by modifying data

Hi All,

I have a SOAP Request where I will be attaching the xml file by modifying a value each time in xml file and executing the request. I need a groovy script for this scenario to automate? Can somebody help me?

Thanks In Advance,
Kiran.
  • Hi Kiran,

    do you mean you want to modify the contents of the attached file for each request?

    regards!

    /Ole
    eviware.com
  • Hi!

    ok.. then I suggest you don't cache the file in the request (when you attach it) and simple modify the file on disk in a groovy script step before the request.

    Does that make sense?

    regards!

    /Ole
    eviware.com
  • Hi Ole,

    Presently I am manually changing the parameter in xml file and attaching the xml file in request attachment and sending request. I am looking for a groovy automation script to automate the process of changing the xml file in disk and send request each time.
  • Hi!

    Exactly, so what you could do is the following;

    1) When you add the attachment, do not select to cache the file in the project. This will result in soapUI reading the file from disk each time it is being attached to a request
    2) Create a groovy script step before your request that modifies the parameters in the file as desired. You can read more about groovy File APIs at http://groovy.codehaus.org/Input+Output

    Does that make sense?

    regards!

    /Ole
    eviware.com