469,609 Members | 2,238 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

System.Net.WebClient HTTP Protocol Error

I am using the System.Net.Webclient to try and download an
XML file from a website but am receiving a HTTP protocol
error when running the DownloadFile() sub routine. I did
a HTTP trace using internet explorer to see what is
happening in the request and it looks as though the
request originates using HTTP/1.1 to an IIS server
authenticates itself but ultimately gets executed by a
Java Application server and when the request is fulfilled
it returns "HTTP/1.0" I'm assuming this is probably
against the HTTP spec and is what is generating the
protocol error? Is there any workaround to this using the
Webclient or am I going to have to approach the problem at
a sockets level, and if so does anyone have a HTTP sockets
client out there that is not the WebClient?

Internet explorer seems to have no problem dealing with
the request and it returns fine in the browser, but when
going at it using the WebClient it errors out.

Here is the request response information for the request
which shows the different protocol versions:
Server Information
IP Address: 192.251.14.15:443
Response Time: 00:00:02.304
Client Request
3 GET /mkt/xml/private/XmlRequest?
request=GENBYPARTICIPANT&DAY=20031007 HTTP/1.1
Header Contents
HTTP/1.0 200 OK

Note:This is only the final request, there are previous
requests which show a 401 denied and it then
authenticates, all using HTTP/1.1 its only the final
request that returns HTTP/1.0
Jul 21 '05 #1
4 14503
I thought I would include some more information to go over. Here is the
exact error that is received:

An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The server
committed an HTTP protocol violation.
This is the code that is generating the error:

Dim myclient As New System.Net.WebClient
Dim mycli As New System.Net.WebPermission

myclient.QueryString = New
System.Collections.Specialized.NameValueCollection

myclient.QueryString.Add("request", "GENBYPARTICIPANT")

myclient.QueryString.Add("DAY", "20031008")

myclient.Credentials = New System.Net.NetworkCredential("USERID",
"PASSWORDS")

myclient.DownloadData("https://xxxxx.xxxxx.com/mkt/xml/private/XmlRequest")
Jul 21 '05 #2
Maybe try WebRequest (not WebClient) ?

System.Net.WebRequest req= System.Net.WebRequest.Create(urlspec);
System.IO.StreamReader sr = new System.IO.StreamReader
(req.GetResponse().GetResponseStream());
result= sr.ReadToEnd ();

The urlspec should be
http://foo.bar/xml/something/fribble...T&DAY=20031008

if you want a credential then you need to do

request.Credentials = System.Net.CredentialCache.DefaultCredentials;

or something similar.

-D

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m
"Justin Malloy" <ju****@nrgonline.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
I thought I would include some more information to go over. Here is the
exact error that is received:

An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The server
committed an HTTP protocol violation.
This is the code that is generating the error:

Dim myclient As New System.Net.WebClient
Dim mycli As New System.Net.WebPermission

myclient.QueryString = New
System.Collections.Specialized.NameValueCollection

myclient.QueryString.Add("request", "GENBYPARTICIPANT")

myclient.QueryString.Add("DAY", "20031008")

myclient.Credentials = New System.Net.NetworkCredential("USERID",
"PASSWORDS")

myclient.DownloadData("https://xxxxx.xxxxx.com/mkt/xml/private/XmlRequest")

Jul 21 '05 #3
Under the covers I believe WebClient is doing the exact same thing, it uses
WebRequest to issue its request. At any rate, I converted the code over to
use WebRequest and the same error was generated when the request went out to
the server. I know its not a problem with authentication because I can
issue an incorrect userid and the server returns me an XML document that
states my userid is incorrect. The odd part is that the authentication
error returns HTTP/1.1 --- which goes back to my original problem where the
final valid request returns HTTP/1.0 which I would guess is causing the
error. I guess I have no problem opening up a phone support incident if
you think this is something they would be able to help me with?


"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:uI**************@TK2MSFTNGP09.phx.gbl...
Maybe try WebRequest (not WebClient) ?

System.Net.WebRequest req= System.Net.WebRequest.Create(urlspec);
System.IO.StreamReader sr = new System.IO.StreamReader
(req.GetResponse().GetResponseStream());
result= sr.ReadToEnd ();

The urlspec should be
http://foo.bar/xml/something/fribble...T&DAY=20031008

if you want a credential then you need to do

request.Credentials = System.Net.CredentialCache.DefaultCredentials;

or something similar.

-D

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m
"Justin Malloy" <ju****@nrgonline.com> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
I thought I would include some more information to go over. Here is the
exact error that is received:

An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The underlying connection was closed: The server
committed an HTTP protocol violation.
This is the code that is generating the error:

Dim myclient As New System.Net.WebClient
Dim mycli As New System.Net.WebPermission

myclient.QueryString = New
System.Collections.Specialized.NameValueCollection

myclient.QueryString.Add("request", "GENBYPARTICIPANT")

myclient.QueryString.Add("DAY", "20031008")

myclient.Credentials = New System.Net.NetworkCredential("USERID",
"PASSWORDS")

myclient.DownloadData("https://xxxxx.xxxxx.com/mkt/xml/private/XmlRequest")


Jul 21 '05 #4
Hello Justin,

Due to the nature of this issue, I would highly recommend you contact
Microsoft Product Support Services since it would require intensive
troubleshooting which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional.

Microsoft support home page: http://support.microsoft.com.

To view support options:
http://support.microsoft.com/default...d=sz;en-us;top.

To submit an online request:
http://support.microsoft.com/default...incidentsubmit.

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Kumar | last post: by
4 posts views Thread by Justin Malloy | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.