473,397 Members | 2,033 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,397 software developers and data experts.

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 15389
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 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...
1
by: ATS | last post by:
ERR - WebClient.DownloadData returns "protocol violation" Please help, I'm getting a "protocol violation" from a site that is working perfectly fine when I issue WebClient.DownloadData as...
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 =...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
1
by: Crirus | last post by:
Hello! Last year I used Framework's 1.0 WebControl to connect to a server designed by me with sockets and TCP. The client run in a html as activex. Right now, I reactivated that project... server...
0
by: MattB | last post by:
Hi, I'm trying to write a simple utility using vb.net that finds my DSL modem's external IP address via it's status page. It seemed simple at first, and I used an example I found online to come up...
4
by: Justin Malloy | last post by:
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...
6
by: | last post by:
I've written a very small ASP.NET page to scrape thousands of pages of content based on database IDs. It loops through a dataset to get the IDs. It worked well in testing but now I am getting an...
1
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.