By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,222 Members | 1,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,222 IT Pros & Developers. It's quick & easy.

C# webclient, uploading a file Error :// Error : Stream ended unexpectedly

P: n/a
Hi,
We are struggeling to upload a file through a C# webClient into JBoss web
server. Meanwhile we are able to upload a file from the webserver itself.
The problem is only with C# webClient . The code is pretty simple.
string uriString = saveTargetToAddress.Text;
string postData = textOutput.Text;

try
{
System.Net.WebClient myWebClient = new System.Net.WebClient();

myWebClient.UploadFile(uriString,"POST","C:\\Share d\\XML\\subflowhandler.xml
");
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}

Please help !!!!

Thank You very much in advance.
PS:
Error : org.apache.commons.fileupload.FileUploadException: Processing of
multipart/form-data request failed. Stream ended unexpectedly
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Have you included the proper length like .content length = sizeof(data)?
Nov 16 '05 #2

P: n/a
No ! What object has these properties ? Any tip how or where to use it
????? I'm using the google but we are not getting it.

Thanks a lot in advance !

"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...
Have you included the proper length like .content length = sizeof(data)?

Nov 16 '05 #3

P: n/a
I might be looking in the wrong direction but nevertheless, WebClient has a
collection of Headers. A Header can be accessed something like so,
Headers["someHeader"]. WebClient should set content length itself when
applicable. Content type header value could be another reason. I don't know
apache but it thinks it gets multipart/form-data and it is not able to
determine the proper length of the data. If connectivity is not the problem
than I would check these headers.

HTH


Nov 16 '05 #4

P: n/a
Actually, we debuged it and we noticed that the headers are OK but the
terminator is missing (Terminator is composed of 2 dashes 0x2D). We compared
the output of the EchoServer from uploading it through TomCat and from C#
webClient and we did see that the termination was missing in webCLient
upload.

Any idea how to set the terminator or to fix this ??????

Any help very much will be apprciated !!!!!
<! this echo came from webClient
EchoServer: got connection from 127.0.0.1
CWU: POST / HTTP/1.1
CWU: Content-Type: multipart/form-data;
boundary=---------------------8c67e9cc5f
f7206
CWU: Content-Length: 446
CWU: Expect: 100-continue
CWU: Connection: Keep-Alive
CWU: Host: localhost:8088
CWU:
CWU: -----------------------8c67e9cc5ff7206
Content-Disposition: form-data; name="file"; filename="subflowhandler.xml"
<!-- this is the information which you are gonna get it from each
subflow(msvis
<classname>aJavaClassName</classname>p NameU="Handler" ID="3">
-----------------------8c67e9cc5ff7206
<! this echo came from webClient>


<! this echo came from TomaCat>

POST / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
application/x-shockwave-flash, */*
Referer: http://localhost:8080/examples/jsp/BrowsePage.jsp
Accept-Language: en-us
Content-Type: multipart/form-data;
boundary=---------------------------7d41112770e48
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
1.1.4322)
Host: localhost:8088
Content-Length: 643
Connection: Keep-Alive
Cache-Control: no-cache

-----------------------------7d41112770e48
Content-Disposition: form-data; name="xpdl"; filename="C:\boot.ini"
Content-Type: application/octet-stream

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="Microso ft Windows 2000
Professional" /fastdetect
Compute
-----------------------------7d41112770e48--



"Joep" <St***@DeStoep.nl> wrote in message
news:41***********************@news.xs4all.nl...
I might be looking in the wrong direction but nevertheless, WebClient has a collection of Headers. A Header can be accessed something like so,
Headers["someHeader"]. WebClient should set content length itself when
applicable. Content type header value could be another reason. I don't know apache but it thinks it gets multipart/form-data and it is not able to
determine the proper length of the data. If connectivity is not the problem than I would check these headers.

HTH

Nov 16 '05 #5

P: n/a
Hello

I see from the error message that the server is expecting a
multipart/form-data content to be uploaded. So instead the server finds just
xml data so it can't parse it. Change your code so that the data uploaded to
the server looks like this:

--abcdefghi
content-disposition: form-data; name="myFile"; filename="subflowhandler.xml"
content-type: text/xml;charset=utf-8
content-transfer-encoding: 8Bit

<data>
xml data goes here
</data>

--abcdefghi--

This example assumes that the page posing to the server has an input file
with name "myFile"
For more information read the RFC2388 at
http://www.faqs.org/rfcs/rfc2388.html

Best regards,
Sherif

"genc ymeri" <ge********@hotmail.com> wrote in message
news:eO*************@TK2MSFTNGP12.phx.gbl...
Hi,
We are struggeling to upload a file through a C# webClient into JBoss web
server. Meanwhile we are able to upload a file from the webserver itself.
The problem is only with C# webClient . The code is pretty simple.
string uriString = saveTargetToAddress.Text;
string postData = textOutput.Text;

try
{
System.Net.WebClient myWebClient = new System.Net.WebClient();

myWebClient.UploadFile(uriString,"POST","C:\\Share d\\XML\\subflowhandler.xml ");
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}

Please help !!!!

Thank You very much in advance.
PS:
Error : org.apache.commons.fileupload.FileUploadException: Processing of
multipart/form-data request failed. Stream ended unexpectedly

Nov 16 '05 #6

P: n/a
Thanks for relpying. The server is getting a multipart/form-data content and
here is what Tomcat is getting

<! this echo came from webClient
EchoServer: got connection from 127.0.0.1
CWU: POST / HTTP/1.1
CWU: Content-Type: multipart/form-data;
boundary=---------------------8c67e9cc5f
f7206
CWU: Content-Length: 446
CWU: Expect: 100-continue
CWU: Connection: Keep-Alive
CWU: Host: localhost:8088
CWU:
CWU: -----------------------8c67e9cc5ff7206
Content-Disposition: form-data; name="file"; filename="subflowhandler.xml"
<!-- this is the information which you are gonna get it from each
subflow(msvis
<classname>aJavaClassName</classname>p NameU="Handler" ID="3">
-----------------------8c67e9cc5ff7206
but the end does not have the last two dashes. Don;t know why.



"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:er**************@TK2MSFTNGP10.phx.gbl...
Hello

I see from the error message that the server is expecting a
multipart/form-data content to be uploaded. So instead the server finds just xml data so it can't parse it. Change your code so that the data uploaded to the server looks like this:

--abcdefghi
content-disposition: form-data; name="myFile"; filename="subflowhandler.xml" content-type: text/xml;charset=utf-8
content-transfer-encoding: 8Bit

<data>
xml data goes here
</data>

--abcdefghi--

This example assumes that the page posing to the server has an input file
with name "myFile"
For more information read the RFC2388 at
http://www.faqs.org/rfcs/rfc2388.html

Best regards,
Sherif

"genc ymeri" <ge********@hotmail.com> wrote in message
news:eO*************@TK2MSFTNGP12.phx.gbl...
Hi,
We are struggeling to upload a file through a C# webClient into JBoss web server. Meanwhile we are able to upload a file from the webserver itself. The problem is only with C# webClient . The code is pretty simple.
string uriString = saveTargetToAddress.Text;
string postData = textOutput.Text;

try
{
System.Net.WebClient myWebClient = new System.Net.WebClient();

myWebClient.UploadFile(uriString,"POST","C:\\Share d\\XML\\subflowhandler.xml
");
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}

Please help !!!!

Thank You very much in advance.
PS:
Error : org.apache.commons.fileupload.FileUploadException: Processing of
multipart/form-data request failed. Stream ended unexpectedly


Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.