Intermountain_H_3
11 years agoContributor
Groovy Code to attach a xml file to the request
Hi all
I have a directory of xml files that I need to attach as attachments to a request
and submit one at a time.
following is the last thing I have tried
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder2 = groovyUtils.getXmlHolder( "documentSubmissionInbound#Request" ) // Get Request body
// get xml files
new File("C://HieGateway_soap//data" ).eachFile{file ->
if(file.name.endsWith(".xml" )){
// clear existing attachments
for( a in holder2.attachments ) {
holder2.removeAttachment( a )
}
holder2.attachFile(file.name,true) // errors here
holder2.contentType = "application/octet-stream"
holder2.setPart( file )
}
}
I will have over 200 of these files so I really dont want to manually add each one at a time
Can u give me advice on what i have wrong if and how this can be done ect
Thanks in advance for your help
I have a directory of xml files that I need to attach as attachments to a request
and submit one at a time.
following is the last thing I have tried
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder2 = groovyUtils.getXmlHolder( "documentSubmissionInbound#Request" ) // Get Request body
// get xml files
new File("C://HieGateway_soap//data" ).eachFile{file ->
if(file.name.endsWith(".xml" )){
// clear existing attachments
for( a in holder2.attachments ) {
holder2.removeAttachment( a )
}
holder2.attachFile(file.name,true) // errors here
holder2.contentType = "application/octet-stream"
holder2.setPart( file )
}
}
I will have over 200 of these files so I really dont want to manually add each one at a time
Can u give me advice on what i have wrong if and how this can be done ect
Thanks in advance for your help