472,952 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

The server committed a protocol violation

A little background:

I've been using web services successfully for a while now. My web server is a Windows CE 4.2 device
and my client is a windows C# application created with Visual Studio 2003. My web server has both
NTLM and Basic authentication. By providing the Credentials for my web service call, my
application can access the web service without any problems.

The problem:

I recently created a new application with Visual Studio 2005 using the same logic. However, when I
try to call the web service, I get a WebException with following message:

"The server committed a protocol violation. Section=ResponseStatusLine"

As soon as I disable the authentication on the web server, the web service call executes without
problems.

To pin-point my problem, I've created a simple test application which merely requests a web page
from the CE device. This test application gives the same error. Here's the code:

HttpWebRequest myWebRequest = WebRequest.Create("http://150.158.204.40/DMS/Installation Manual.htm")
as HttpWebRequest;
NetworkCredential networkCredential = new NetworkCredential("Test", "service");
myWebRequest.Credentials = networkCredential;
try
{
WebResponse myWebResponse = myWebRequest.GetResponse();
MessageBox.Show(myWebResponse.ContentLength.ToStri ng());
}
catch (WebException wex)
{
Trace.WriteLine(string.Format("Caught Exception: {0}", wex.Message));
Trace.WriteLine(string.Format("Stack: {0}", wex.StackTrace));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

I've enabled Network Tracing for this test application and I got following output (using Basic
authentication):

System.Net Verbose: 0 : [4952] WebRequest::Create(http://150.158.204.40/DMS/Installation Manual.htm)
System.Net Verbose: 0 : [4952]
HttpWebRequest#63840421::HttpWebRequest(http://150.158.204.40/DMS/Installation Manual.htm#1606441202)
System.Net Verbose: 0 : [4952] Exiting HttpWebRequest#63840421::HttpWebRequest()
System.Net Verbose: 0 : [4952] Exiting WebRequest::Create() -HttpWebRequest#63840421
System.Net Verbose: 0 : [4952] HttpWebRequest#63840421::GetResponse()
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421 with ServicePoint#54246671
System.Net Information: 0 : [4952] Associating Connection#25181126 with HttpWebRequest#63840421
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421 with ConnectStream#59408853
System.Net Information: 0 : [4952] HttpWebRequest#63840421 - Request: GET
/DMS/Installation%20Manual.htm HTTP/1.1

System.Net Information: 0 : [4952] ConnectStream#59408853 - Sending headers
{
Host: 150.158.204.40
Connection: Keep-Alive
}.
System.Net Information: 0 : [4952] Connection#25181126 - Received status line: Version=1.0,
StatusCode=401, StatusDescription=Unauthorized.
System.Net Information: 0 : [4952] Connection#25181126 - Received headers
{
Date: Tue, 11 Jul 2006 20:55:59 GMT
Connection: keep-alive
Server: Microsoft-WinCE/4.20
WWW-Authenticate: NTLM,Basic realm="Microsoft-WinCE"
Content-Type: text/html
Content-Length: 81
}.
System.Net Information: 0 : [4952] ConnectStream#56152722::ConnectStream(Buffered 81 bytes.)
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421 with ConnectStream#56152722
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421 with HttpWebResponse#43844556
System.Net Warning: 0 : [4952] HttpWebRequest#63840421::() - Resubmitting request.
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421 with ServicePoint#54246671
System.Net Information: 0 : [4952] Associating Connection#25181126 with HttpWebRequest#63840421
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421 with ConnectStream#26847985
System.Net Information: 0 : [4952] HttpWebRequest#63840421 - Request: GET
/DMS/Installation%20Manual.htm HTTP/1.1

System.Net Information: 0 : [4952] ConnectStream#26847985 - Sending headers
{
Authorization: Basic UEZFOnZpc2lvbg==
Host: 150.158.204.40
Connection: Keep-Alive
}.
System.Net Error: 0 : [4952] Exception in the HttpWebRequest#63840421:: - The server committed a
protocol violation. Section=ResponseStatusLine
System.Net Error: 0 : [4952] Exception in the HttpWebRequest#63840421::EndGetResponse - The server
committed a protocol violation. Section=ResponseStatusLine
A first chance exception of type 'System.Net.WebException' occurred in System.dll

When I look with Ethereal, I get following stream:

Request ->
GET /DMS/Installation%20Manual.htm HTTP/1.1
Host: 150.158.204.40
Connection: Keep-Alive

Response ->
HTTP/1.0 401 Unauthorized
Date: Tue, 11 Jul 2006 20:55:59 GMT
Connection: keep-alive
Server: Microsoft-WinCE/4.20
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="Microsoft-WinCE"
Content-Type: text/html
Content-Length: 81

Request ->
GET /DMS/Installation%20Manual.htm HTTP/1.1
Authorization: Basic UEZFOnZpc2lvbg==
Host: 150.158.204.40
Connection: Keep-Alive

Response ->
<B>Access denied.</B><P>Client does not have access to the resource on the serverHTTP/1.0 200 OK
Date: Tue, 11 Jul 2006 20:55:59 GMT
Connection: keep-alive
Server: Microsoft-WinCE/4.20
Last-Modified: Mon, 10 Jul 2006 12:23:36 GMT
ETag: "0149baa1ba4c61:820:7"
Content-Type: text/html
Content-Length: 37462

<html>
<head>
<meta http-equiv="Content-Language" content="nl-be">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Installation Manual</title>
</head>
<body>
....

As you can see in the HTTP stream captured with Ethereal, the first request fails with an error,
because no Authentication is used. The application then tries again with an Authorization string in
the header. This request succeeds and the CE device start sending the HTML content. However, the
..NET framework seems to ignore this content and throws the WebException instead.

Note that I've already tried to add the "useUnsafeHeaderParsing" in the config file, but without
success.

Does anyone have an idea what could be causing this problem?
Or how I can further debug this problem?

I've you need more tracing, please let me now.

Regards
Kris
Jul 11 '06 #1
0 8774

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan W. | last post by:
Does anyone have any experience with this problem. I am trying to post about 20 fields of information to another server using System.Net.WebClient.UploadData. This works fine for some servers but...
1
by: pmclinn | last post by:
I keep getting the following error: The underlying connection was closed: The server committed an HTTP protocol violation. I have tried putting the <configuration> <system.net> <settings>...
1
by: Dan W. | last post by:
Does anyone have any experience with this problem. I am trying to post about 20 fields of information to another server using System.Net.WebClient.UploadData. This works fine for some servers but...
3
by: Scott McDermott | last post by:
I have an application that is making an HTTP request with HttpWebRequest.GetRequest. Unless I set 'httpWebRequest useUnsafeHeaderParsing="true"' in the web.config, I get a 'The server committed a...
0
by: Vel Thavasi | last post by:
Hi, I am trying to access third party webservices and I am getting 2 different error msgs. 1) Server committed a protocol violation. 2) Content is not allowed in prolog. I searched through...
0
by: Edwardseok | last post by:
Hello All, I am making VB.NET application program to read data from other equipment. The following is my code.(VB2005.NET) ---------------code -------------------------- Private Sub...
3
by: Alon Albert | last post by:
I have an ASP.NET that has an aspx that serves a binary file for download. I need this rather than a direct link for various reasons. I am getting the following error intermitently: The server...
0
by: oriol.ardevol | last post by:
Hi, I have an asp.net application that connects through an HttpWebRequest object to a ISAPI dll in a server. This isapi dll has some different method calls. What I do is calling the different...
0
by: phuc2583 | last post by:
Please help me when i submit to run the web server but i give a error below Unable to start debugging on the web server the server committed a protocol violation Section=ResponseStatusLine Thanks...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.