Upload xml file- HttpWebRequest

R

Rob

I'm trying to translate the following code in vb.net code to be used in a
web service. Really I can't understand well it. I would like to use
httpWebRequest but I don't know.... Do I have to use headers? How can I
translate the "requestbody" string?

The code sends an xml file and a command.


fso = new ActiveXObject("Scripting.FileSystemObject");
xmlFile = fso_OpenTextFile(AJobFile, 1);
xmlText = xmlFile.ReadAll();

var boundStr = 'h8w95k20d9';
var boundary = '--' + boundStr;

var requestbody = [boundary,
'Content-Disposition: file; name="F1";
filename="'+AJobFile+'"',
'Content-Type: text/xml',
'',
xmlText,

boundary,
'Content-Disposition: form-data; name="ImportJobs"',
'',
'0',
boundary
].join('\r\n');

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
url='http://'+WODAddress+'/JTI';

xmlhttp.open("POST",url,false);
xmlhttp.setRequestHeader('Content-type', 'multipart/form-data; boundary="'
+ boundStr + '"');
xmlhttp.send(requestbody );
 
B

bruce barker

yes. its a standard browser fileupload. check the w3c specs to understand the
format:

http://www.w3.org/Protocols/

or you can use webclient which has support for this (fileupload). just be
sure to set the content-type.


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top