473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
6 12205
Have you included the proper length like .content length = sizeof(data)?
Nov 16 '05 #2
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
3
by: Michael Fields | last post by:
I have a problem with the WebClient and uploading a file to a web server. The stream object returned from the WebClient.OpenWrite menthod throws a timeout exception when using this method on...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
3
by: Manuel | last post by:
I have an asp page ("test.asp") that presents the data it receives from a post.When I try the following code, test.asp doesn't return the values (supposedly) posted to it. If I make a web page with...
2
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
1
by: Chris Dunaway | last post by:
I am using the following code to test an .aspx page which has no presentation and only a handler for the Page_Load event. I am using this code to POST the contents of an .xml file to the .aspx...
0
by: natzol | last post by:
Hello, I need to provide the ability to post file and some form elements via our website (asp.net) to the third party website (asp page). On http://aspalliance.com/236#Page4 - I found great...
4
by: Natalia | last post by:
Hello, I need to provide the ability to post file and some form elements via our website (asp.net) to the third party website (asp page). On http://aspalliance.com/236#Page4 - I found great...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.