Forum Discussion
19 Replies
Sort By
- omatzuraSuper ContributorHi!
Quick walkthrough:
1) Create a new Project
2) Create a TestSuite in the Project
3) Create a TestCase in the TestSuite
4) Add an HTTP TestRequest Step to the TestCase
-> Set the endpoint to the URL you want to upload to
-> Set the method to POST (or PUT)
5) In the Request Editor add the File you want to upload to the Attachments tab
6) Set the Media-Type of the POST Body to the same as the Content-Type of the attached File
7) Send the request!
Hope I got that right :-)
/Ole
eviware.com - aaron_ehrensberContributorIs there anyway to add files dynamically - ie - read in 20 files out of a datasource and toss them in 20 concurrent threads for 20 requests? Using the attachment button wouldn't allow this would it?
aaron - omatzuraSuper ContributorHi!
would you store the files themselves in the DataSource or just the filenames?
regards,
/Ole
eviware.com - aaron_ehrensberContributorIdeally, just the filenames.
So, store the filenames in a datasource and retrieve the name. I can do this....
But how do I build the actual HTTP Request with the changing filename representing the file I want to attach? That's my core question.
aaron - omatzuraSuper ContributorHi,
you can either create a groovy script that does the actual attaching of the file or you can use property-expansion in the filename of the attachment and set it to not be cached.
Hope this helps!
regards,
/Ole
eviware.com - aaron_ehrensberContributorI'd like to use a groovy script to attach the file, but this is probably a question I should have asked long ago....
How do I know the syntax to use? Is there a Groovy API somewhere? A soapUI api somewhere? I feel a lot of my questions might have been avoided if I truly knew where to look for an api-type answer.
aaron - omatzuraSuper ContributorHi!
you can do something like the following:// get request
def request = testRunner.testCase.getTestStepByName( "Request" ).testRequest
// clear existing attachments
for( a in request.attachments ) {
request.removeAttachment( a )
}
// get file to attach
def file = new File( "file to attach" )
if ( file == null) {
log.info "bad filename"
}
else
{
// attach and set properties
def attachment = request.attachFile( file, true )
attachment.contentType = "application/octet-stream"
attachment.setPart( "Message" )
}
This should get you started..
regards,
/Ole
eviware.com - Chris_MNew ContributorI also want to upload a file, but in this case it is an audio file that gets submitted to the web service. The problem I am having is that it is naturally encoded when uploaded to a web service via a windows form, but not automatically encoded when submitted via SOAP UI.
When I wrote the client in visual studio I did not do anything other than add a box to browse to the file. I'm not sure how or why the windows form handles this automatically.
Thank you,
Chris - omatzuraSuper ContributorHi Chris,
Hmm.. How do you want the file to be encoded?
regards!
/Ole
eviware.com - Chris_MNew ContributorOmatzura,
I was looking at the wsdl and it specifies the datatype as Base64 encoding. I believe that Visual Studio sees this when you add the web service reference and automatically encodes the file.
~chris
Related Content
Recent Discussions
- 5 days agosmilnik