Forum Discussion

uwe75's avatar
uwe75
New Contributor
8 years ago

replace tag value with content from file

Hello,

 

I am trying to automate testing of a web service by filling in tags in my request(s) with values coming from a file. Since the "Data Source" test step is not available in SoadUI open source I am trying to implement groovy scripts as described in https://learnsoapui.wordpress.com/2012/05/19/groovy-datasource-teststep-dataloop-teststep-using-groovy-in-soapui/

 

This works actually quite well; I can read all values in my file and the values are written into the Property - Looper / Value field in a successive manner. However, the script does not actually update the xml of my mock request; I could not even find a statement that tries it.

 

I wanted to use a statement like this which should replace the content of the the tag ltNomenclature with the value read from file present in the tempValue variable:

def node = xml.'testCase'.findAll { it.name() == 'ltNomenclature' }.each{ it.replaceBody(tempValue) }

 

However, this is not all that is needed, xml must be defined beforehand. How can I do this to make it reference my mock request ? All examples that I found in the forums concern parsing xml from file using xmlslurper but not from within the test case suite itself.

 

Many thanks for any hints you could give.  Cheers, Uwe

3 Replies

  • uwe75's avatar
    uwe75
    New Contributor

    Found a way; in addition to writing the desired value to a property I created a new test step of the type "Property Transfer" that injects it into the xml.

     

    Took ages to find I lost much time trying to replace the xml content directly.

    • nmrao's avatar
      nmrao
      Champion Level 3
      You should not worry, happens for every while learning. The best thing is that It is now on your finger tips which I believe will be with you for the rest of the life.
    • neham's avatar
      neham
      Occasional Visitor

      uwe75 

      Can you please explain in detail how to replace tag element in xml.

      Actual problem statement is:

      URL tag from 10 xml has to be replaced from 10 other xml through soap ui as i have to check response of each using wsdl link.

      It would be very helpful if you explain looping these xml to replace element value