HTTP 401/200 request pair on every Web Service call

E

Erik S.

When I am issuing multiple authenticated requests against the Web Service a
get a HTTP 401/200 request pair on every request. The Web Service is hosted
on a virtual directory which disallows anonymous access and has integrated
windows authentication enabled.

To isloate the problem I created a web service project in Visual Studio
2003. De service has one simple web method.

public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(string hello)
{
return hello + " from " + Thread.CurrentPrincipal.Identity.Name;
}
}

Then I created a project for a console application. This console application
calls the web service three times.

class Class1
{
static void Main(string[] args)
{
TestWebService.Service1 svc1 = new Service1();
svc1.Credentials = CredentialCache.DefaultCredentials;
svc1.PreAuthenticate = true;

Console.WriteLine(svc1.HelloWorld("Hello"));

svc1.Dispose();

TestWebService.Service1 svc2 = new Service1();
svc2.Credentials = CredentialCache.DefaultCredentials;
svc2.PreAuthenticate = true;

Console.WriteLine(svc2.HelloWorld("world!"));
Console.WriteLine(svc2.HelloWorld("Hello world!"));

svc2.Dispose();
}
}

The web service works fine. When the web service is deployed on Windows XP
there is only one HTTP 401 error in the IIS Log. After that all subsequent
calls are executed without HTTP 401 errors. This is how it should work (the
initial 401 challenge).
If I deploy the web service on Windows 2003 SP 2 every call generates a HTTP
401 error as shown below. It happens on different servers, with and without
using a load balancer. Maybe the connection is not kept alive, but default it
should.

#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2007-11-21 16:20:27
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port
cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status
2007-11-21 16:20:27 10.241.14.117 POST /TestWebService1/Service1.asmx - 80 -
10.241.11.127
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+1.1.4322.2407) 401 2 2148074254
2007-11-21 16:20:27 10.241.14.117 POST /TestWebService1/Service1.asmx - 80 -
10.241.11.127
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+1.1.4322.2407) 401 1 0
2007-11-21 16:20:45 10.241.14.117 POST /TestWebService1/Service1.asmx - 80
somename 10.241.11.127
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+1.1.4322.2407) 200 0 0
2007-11-21 16:20:48 10.241.14.117 POST /TestWebService1/Service1.asmx - 80 -
10.241.11.127
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+1.1.4322.2407) 401 1 0
2007-11-21 16:20:48 10.241.14.117 POST /TestWebService1/Service1.asmx - 80
somename 10.241.11.127
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+1.1.4322.2407) 200 0 0
2007-11-21 16:20:48 10.241.14.117 POST /TestWebService1/Service1.asmx - 80 -
10.241.11.127
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+1.1.4322.2407) 401 1 0
2007-11-21 16:20:48 10.241.14.117 POST /TestWebService1/Service1.asmx - 80
somename 10.241.11.127
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+1.1.4322.2407) 200 0 0

The same problem is mentioned on:
http://www.dotnet247.com/247reference/msgs/25/128355.aspx
I don't understand how the solution suggested there could help me.

Everything works, but the 401 error slows down the calls with up to 200
milliseconds.

Any help will be greatly appreciated.

Thanks,
Erik S.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top