System.Net.WebClient HTTP Protocol Error

J

Justin Malloy

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
 
J

Justin Malloy

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")
 
D

Dino Chiesa [Microsoft]

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?request=GENBYPARTICIPANT&DAY=20031008

if you want a credential then you need to do

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

or something similar.

-D
 
J

Justin Malloy

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?
 
T

Tian Min Huang

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.aspx?scid=sz;en-us;top.

To submit an online request:
http://support.microsoft.com/default.aspx?scid=fh;en-us;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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top