473,574 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = saveTargetToAdd ress.Text;
string postData = textOutput.Text ;

try
{
System.Net.WebC lient myWebClient = new System.Net.WebC lient();

myWebClient.Upl oadFile(uriStri ng,"POST","C:\\ Shared\\XML\\su bflowhandler.xm l
");
}
catch (Exception Ex)
{
MessageBox.Show (Ex.Message);
}

Please help !!!!

Thank You very much in advance.
PS:
Error : org.apache.comm ons.fileupload. FileUploadExcep tion: Processing of
multipart/form-data request failed. Stream ended unexpectedly
Nov 16 '05 #1
6 12225
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="subfl owhandler.xml"
<!-- this is the information which you are gonna get it from each
subflow(msvis
<classname>aJav aClassName</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:\bo ot.ini"
Content-Type: application/octet-stream

[boot loader]
timeout=30
default=multi(0 )disk(0)rdisk(0 )partition(2)\W INNT
[operating systems]
multi(0)disk(0) rdisk(0)partiti on(2)\WINNT="Mi crosoft 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="subfl owhandler.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********@hot mail.com> wrote in message
news:eO******** *****@TK2MSFTNG P12.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 = saveTargetToAdd ress.Text;
string postData = textOutput.Text ;

try
{
System.Net.WebC lient myWebClient = new System.Net.WebC lient();

myWebClient.Upl oadFile(uriStri ng,"POST","C:\\ Shared\\XML\\su bflowhandler.xm l ");
}
catch (Exception Ex)
{
MessageBox.Show (Ex.Message);
}

Please help !!!!

Thank You very much in advance.
PS:
Error : org.apache.comm ons.fileupload. FileUploadExcep tion: 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="subfl owhandler.xml"
<!-- this is the information which you are gonna get it from each
subflow(msvis
<classname>aJav aClassName</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.NO SPAM> wrote in message
news:er******** ******@TK2MSFTN GP10.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="subfl owhandler.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********@hot mail.com> wrote in message
news:eO******** *****@TK2MSFTNG P12.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 = saveTargetToAdd ress.Text;
string postData = textOutput.Text ;

try
{
System.Net.WebC lient myWebClient = new System.Net.WebC lient();

myWebClient.Upl oadFile(uriStri ng,"POST","C:\\ Shared\\XML\\su bflowhandler.xm l
");
}
catch (Exception Ex)
{
MessageBox.Show (Ex.Message);
}

Please help !!!!

Thank You very much in advance.
PS:
Error : org.apache.comm ons.fileupload. FileUploadExcep tion: 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
942
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 during a webclient request" .._Hresult = "-2146233079" .._COMPlusExceptionCode ="-532459699" Sorry I don't have the whole error, but this seems to...
3
15087
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 computers w/ low bandwith ( < = 256 kbs). The exception occurs when I call the Stream.Close method. Here is the code: WebClient client = new...
6
13274
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 = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileID.ToString() + ".pdf");
13
4293
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 that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I...
3
7565
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 a form and the values, test.asp reports them fine. ---------------------------- Dim thePost As String =...
2
5962
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 application to download images using System.NET classes (webclient, webrequest) asynchronously behind proxy server. The reading method works like...
1
1315
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 page. The page received the file just find and uses Response.Write to send back a response to indicate it received the file. I am at a loss to...
0
1460
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 advices but still having troubles... it might some obvious error that I am making but I just dont see it. ==================FIRST -...
4
12696
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 advices but still having troubles... it might some obvious error that I am making but I just dont see it. ==================FIRST -...
0
7747
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7843
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8129
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6498
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3768
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2262
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1364
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1094
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.