cancel
Showing results for 
Search instead for 
Did you mean: 

Use a file in a SOAP request

SOLVED
Highlighted
Occasional Contributor

Use a file in a SOAP request

Hi all, 

I need to know how do this process.

I have a SOAP request that give a attachment file (see File1.PNG) and need to process the file for other request.

How can use it automatically?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: Use a file in a SOAP request

The solution is here: 

 

def testCaseName = 'Messages-IP-Mail'
def testStepName = '001_1ConventMailToPDF'
//context.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].testRequest.responseContent
def projectDir = context.expand('${projectDir}');
log.info "Current dir:" + projectDir
def response = context.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].testRequest.response.getAttachments()
def fileName = projectDir + '/pdf.pdf'
def outFile = new FileOutputStream(new File(fileName))
testRunner.testCase.testSteps["testStepName"].setPropertyValue("fileName", fileName)
def ins = response[0].inputStream
if (ins) {
       com.eviware.soapui.support.Tools.writeAll(outFile, ins)
    }
ins.close()
outFile.close()
3 REPLIES 3
Community Hero

Re: Use a file in a SOAP request

Hi @icenamor 

 

I was going to try and explain - but the help is pretty good on this - please see the following 2 soapui and readyapi! links.

 

ah - I just re-read your message - are you saying you get a .png file in a SOAP response and you need to pass this onto a subsequent SOAP request?  Anyway - have a look at the links to familiarise yourself -  if this is the case just get things setup to send a file first and then worry about passing it from a response to a request afterwards

 

Cheers,

 

rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Community Hero

Re: Use a file in a SOAP request

If the issue is to save the file automatically, then refer below thread:
https://community.smartbear.com/t5/SoapUI-Open-Source/Save-attachments-automatically-in-SoapUI-with-...


Regards,
Rao.
Occasional Contributor

Re: Use a file in a SOAP request

The solution is here: 

 

def testCaseName = 'Messages-IP-Mail'
def testStepName = '001_1ConventMailToPDF'
//context.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].testRequest.responseContent
def projectDir = context.expand('${projectDir}');
log.info "Current dir:" + projectDir
def response = context.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].testRequest.response.getAttachments()
def fileName = projectDir + '/pdf.pdf'
def outFile = new FileOutputStream(new File(fileName))
testRunner.testCase.testSteps["testStepName"].setPropertyValue("fileName", fileName)
def ins = response[0].inputStream
if (ins) {
       com.eviware.soapui.support.Tools.writeAll(outFile, ins)
    }
ins.close()
outFile.close()
New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors