HTTP Upload vs. SOAP Request (how they are different)

What is the difference between an HTTP Upload and a SOAP Request?

An upload is an HTTP request that uses the multipart/form-data content-type. (All HTTP requests and responses are MIME, and the format of a given request is determined by the content-type.) A SOAP request, on the other hand, has a content-type of text/xml, which means it is composed of a MIME header + body, where the body contains the SOAP XML. Whereas an upload is a multipart MIME structure, where each sub-part contains either the content of a file, or a name/value parameter.

Here are some examples. First a very simple HTTP upload as produced by this C++ fragment:

CkUpload upload;
CkUrl url;

url.ParseUrl("https://www.some-web-server.com/receiveTheUpload.aspx");

upload.put_Hostname(url.host());
upload.put_Path(url.path());
upload.put_Port(url.get_Port());

upload.AddCustomHeader("MyCustomRequestHeader","abc 123");

upload.AddFileReference("TinyA","qa_data/xml/tinyA.xml");

CkByteData uploadData;
upload.UploadToMemory(uploadData);
uploadData.saveFile("qa_output/uploadData1.txt");

The HTTP request (which is MIME, and by the way, and emails are also composed of MIME, so understanding a bit about MIME will do one good because it is so central to Internet technologies..) looks like this:

POST /receiveTheUpload.aspx HTTP/1.1
Host: www.some-web-server.com
User-Agent: ChilkatUpload/3.0 (http://www.chilkatsoft.com/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
Expect: 100-continue
MyCustomRequestHeader: abc 123
Content-Type: multipart/form-data; boundary=---------------------------DD1A174A4121EDFD
Content-Length: 206

-----------------------------DD1A174A4121EDFD
Content-Disposition: form-data; name="TinyA"; filename="tinyA.xml"
Content-Type: text/xml

<tiny>A</tiny>
-----------------------------DD1A174A4121EDFD--

A SOAP XML request, as sent by this fragment of C++ code:

CkHttp http;

http.put_SessionLogFilename("qa_output/xmlPostLog.txt");

// The URL used here is junk and will result in a 404 not found. 
// (We don't care about the response, we
// are only interested in understanding the format of the HTTP request sent.)
// Imagine the XML passed in the 2nd argument is actually a SOAP XML document... 

CkHttpResponse *resp = http.PostXml("http://www.chilkatsoft.com/mywebservice",
    "<tiny>A</tiny>","utf-8");
delete resp;

Looks like this:

(Imagine the XML is actually a SOAP XML document..)

POST /mywebservice HTTP/1.1
Content-Type: text/xml
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip
Host: www.chilkatsoft.com
Content-Length: 14

<tiny>A</tiny>

An HTTP upload containing two file is produced by this fragment of code:

CkUpload upload;
CkUrl url;

url.ParseUrl("https://www.some-web-server.com/receiveTheUpload.aspx");

upload.put_Hostname(url.host());
upload.put_Path(url.path());
upload.put_Port(url.get_Port());

upload.AddCustomHeader("MyCustomRequestHeader","abc 123");

upload.AddFileReference("TinyA","qa_data/xml/tinyA.xml");
upload.AddFileReference("TinyB","qa_data/xml/tinyB.xml");

CkByteData uploadData;
upload.UploadToMemory(uploadData);
uploadData.saveFile("qa_output/uploadData2.txt");

And the HTTP request looks like this:

POST /receiveTheUpload.aspx HTTP/1.1
Host: www.some-web-server.com
User-Agent: ChilkatUpload/3.0 (http://www.chilkatsoft.com/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
Expect: 100-continue
MyCustomRequestHeader: abc 123
Content-Type: multipart/form-data; boundary=---------------------------6F87F47E0974A38B
Content-Length: 363

-----------------------------6F87F47E0974A38B
Content-Disposition: form-data; name="TinyA"; filename="tinyA.xml"
Content-Type: text/xml

<tiny>A</tiny>
-----------------------------6F87F47E0974A38B
Content-Disposition: form-data; name="TinyB"; filename="tinyB.xml"
Content-Type: text/xml

<tiny>B</tiny>
-----------------------------6F87F47E0974A38B--

Finally, an HTTP upload with multiple files and a few name/value params is produced by this C++ fragment:

CkUpload upload;

CkUrl url;

url.ParseUrl("https://www.some-web-server.com/receiveTheUpload.aspx");

upload.put_Hostname(url.host());
upload.put_Path(url.path());
upload.put_Port(url.get_Port());

upload.AddCustomHeader("MyCustomRequestHeader","abc 123");

upload.AddParam("ParamA","This is the value for param A");
upload.AddParam("ParamB","This is the value for param B");

upload.AddFileReference("TinyA","qa_data/xml/tinyA.xml");
upload.AddFileReference("TinyB","qa_data/xml/tinyB.xml");

CkByteData uploadData;
upload.UploadToMemory(uploadData);
uploadData.saveFile("qa_output/uploadData3.txt");

And the HTTP request looks like this:

POST /receiveTheUpload.aspx HTTP/1.1
Host: www.some-web-server.com
User-Agent: ChilkatUpload/3.0 (http://www.chilkatsoft.com/)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
Expect: 100-continue
MyCustomRequestHeader: abc 123
Content-Type: multipart/form-data; boundary=---------------------------EFC8C527CC836355
Content-Length: 617

-----------------------------EFC8C527CC836355
Content-Disposition: form-data; name="ParamA"

This is the value for param A
-----------------------------EFC8C527CC836355
Content-Disposition: form-data; name="ParamB"

This is the value for param B
-----------------------------EFC8C527CC836355
Content-Disposition: form-data; name="TinyA"; filename="tinyA.xml"
Content-Type: text/xml

<tiny>A</tiny>
-----------------------------EFC8C527CC836355
Content-Disposition: form-data; name="TinyB"; filename="tinyB.xml"
Content-Type: text/xml

<tiny>B</tiny>
-----------------------------EFC8C527CC836355--

FTP Upload Files to Web Server?

Question:
We are trying out the FTP2 ActiveX component for ASP. What we need to do is
have people be able to upload files to the web server over the Internet. Is
this component able to do this – or can it only FTP files that are already on the
web server?

Answer:
This is a common question. The need is to upload files from the user’s computer (i.e. the computer where the browser is running) to the web server. You should remember that your ASP code is running on the server (not on the computer where the browser is running). Therefore, any code within your ASP will only have access to the files on the web server. What you really want is to do a simple HTTP file upload from the browser. You’ll need to provide both client-side and server-side code to implement the HTTP upload. The client-side is extremely easy — you simply create a form with “file” type input tags:

<html>
<body>
<form method="POST" enctype="multipart/form-data" action = "http://www.mywebserver.com/ReceiveUpload.aspx" >
<input name=attach1 type=file size=20><br>
<input name=attach2 type=file size=20><br>
<input type=submit value="Upload">
</form>
</body>
</html>

The above form uploads two files, and also sends a few extra (non-file) form fields. To upload a single file, simply remove one of the “input” HTML tags.

Receiving the upload on the server-side requires programming.  It can be done in classic ASP, ASP.NET, Perl, a C++ CGI, etc.

Here are examples for classic ASP and ASP.NET:

Receive HTTP Upload Files in Classic ASP

Receive HTTP Uploads directly into memory in Classic ASP

Receive Upload + additional form fields in Classic ASP

Complete ASP.NET (C#) HTTP Upload Example

Debugging HTTP Upload

HTTP upload requires code both client-side and server-side code to be functioning correctly. Imagine you are trying to do an HTTP upload from your application (using the Chilkat Upload component) and something is not working. How do you debug? Is the client-side application at fault? Is the Chilkat Upload component not working correctly? Is the server-side code that receives the upload not functioning correctly? (Remember, w/ HTTP upload you must write the server-side code to receive the upload.)

A good way to debug is to substitute a web browser (FireFox or Internet Explorer) for the client-side. You can be assured that the browser will perform the client-side of the upload correctly. If the upload fails using a browser, then the problem must be on the server-side. (Or it’s possible there are problems in your client-side application AND the server-side, but by using the web browser you can test your server-side independently of your client-side.)

To upload from a browser, simply create an HTML page with a form like this:

<html>
<body>
<form method="POST" enctype="multipart/form-data" action = "http://www.mywebserver.com/ReceiveUpload.aspx" >
<input name=hid1 type=hidden value="test123">
<input name=hid2 type=hidden value="abcdef">
<input name=attach1 type=file size=20><br>
<input name=attach2 type=file size=20><br>
<input type=submit value="Upload">
</form>
</body>
</html>

The above form uploads two files, and also sends a few extra (non-file) form fields. To upload a single file, simply remove one of the “input” HTML tags.

In summary: If the upload using a browser fails, you should focus on getting your server-side code working correctly. Once uploading with a browser is successful, you should then test your client-side code. It is now known that your server-side code is receiving the upload properly, so if your client-side code fails, there must be a problem with it.

IIS 6.0 Upload Size Limit

The AspMaxRequestEntityAllowed Metabase Property (IIS 6.0) specifies the maximum number of bytes allowed in the entity body of an ASP request. The default value is 2MB. To upload files greater than this size, this IIS metabase property must be changed on the server.

File Upload Limits in IIS7 – Increasing the Size Limit

A web application running in IIS7 on Windows Server 2008 will reject any upload that is larger than 30MB. This is the default size limit for IIS7. To increase the maximum file size, add the following code to <system.webServer> in the web.config file:
(This example sets the limit to 500MB)

<security>
 <requestFiltering>
  <requestLimits maxAllowedContentLength=”500000000″ />
 </requestFiltering>
</security>

You must restart IIS for the setting to take effect.