Contributions
- 1.5KViews0likes0Comments
Re: Dynamic XML generation in Request
Hi Shonzilla, Thank you for the response. As I do not have Pro at the moment, I am trying to think up other ways to generate the XML. At this point I feel as though it can be done using Groovy to read in a flatfile of name=value pairs, parse out the name=value pairs, and build the XML via importing groovy.xml.MarkupBuilder. Since I am shifting gears more on the XML builder aspect of things, here is the code I'm starting with: import groovy.xml.MarkupBuilder def writer = new StringWriter() def xml = new MarkupBuilder( writer ) def list = [] new File("filename.txt").eachline { line -> list.add( line ) } context.setProperty( "values", list ) context.setProperty( "index", 0 ) def values = context.getProperty( "values" ) def index = context.getProperty( "index" ) while( index < values.size() ) { def str = values[index] def parseValue = str.indexOf( "=" ) def nextValueName = str.substring( 0, parseValue ) def nextValue = str.substring( parseValue+1 ) xml."$nextValueName"( nextValue ) index++ } outPath = "filename.xml" outFile = new File( outPath ) outFile << writer With this code, filename.xml is simply a list of XML tags with the respective values in each tag. So if we take my example above, a flatfile with name=value pairs of: field1=1 field2=2 field3=3 field1=4 field2=5 field3=6 would generate the following: 1 2 3 4 5 6 I would need some way to get the following xml output: 1 2 3 4 5 6 I am new to this (only started playing with this last week). Perhaps a better question would be, is there a comprehensive "using Groovy to build XML" guide out there I can start reading? Again, Thank you very much for your patience and assistence. ~Greg1.5KViews0likes0CommentsDynamic XML generation in Request
Greetings, I was wondering if SoapUI has the capability to generate XML tags in the request message. example of what I am asking - take this generic soap request: 1 2 3 In this example, fields 1 2 and 3 are being parsed out from a .txt file: field1=1 field2=2 field3=3 and my Properties step is being populated accordingly. However, I would like to be able to parse out a .txt file that might have these fields repeating, i.e. simulating multiple rows from a database so the .txt file would look somthing like follows: field1=1 field2=2 field3=3 field1=4 field2=5 field3=6 My script will overwrite the Properties in my testCase with 4, 5 & 6 respectively (although this is a different issue). I'd like to find a way to dynamically generate 3 new xml tags in this case for the request message, to look like the following: 1 2 3 4 5 6 Thank you in advance for any advice you may provide. If my question is unclear, I will gladly provide more detail where possible. ~Greg3.1KViews0likes5Comments