ProtocolError unauthorized with webservice calls

  • Thread starter Jeffry van de Vuurst
  • Start date
J

Jeffry van de Vuurst

Hi,

I have a CF 2.0 application that uses webservices to sync data. It has a
background sync running that looks for changes at a specified interval. It
happens on WM6 and I don't know if it also happens on WM5.

In general this works fine, but sometimes I see a lot of WebExceptions in
the logfile. The status is ProtocolError and description is "unauthorized".

IIS is configured to only allow Integrated Windows Authentication.

I've looked in the IIS log files and this is what I see when the webservice
calls fails (ip addresses left out):
2007-11-26 10:18:34 W3SVC1863281234 xxx.xxx.x.x POST /webservice.asmx -
5556 - xx.xxx.xxx.xx
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+.NET+CF+Web+Services+Client+Protocol+2.0.7045.0)
401 2 2148074254

What's important about this are the last 3 values, especially 401 2, which
means "401.2 - Logon failed due to server configuration".

When the webservice call succeeds I see the following entries:
2007-11-26 15:21:00 W3SVC1863281234 xxx.xxx.x.x POST /webservice.asmx -
5556 - xx.xxx.xxx.xx
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+.NET+CF+Web+Services+Client+Protocol+2.0.7045.0)
401 1 0
2007-11-26 15:21:01 W3SVC1863281234 xxx.xxx.x.x POST /webservice.asmx - 5556
DOMAIN\account xx.xxx.xxx.xx
Mozilla/4.0+(compatible;+MSIE+6.0;+MS+.NET+CF+Web+Services+Client+Protocol+2.0.7045.0)
200 0 0

So when the call succeeds it first receives a 401.1 - Logon failed. This is
AFAIK the basic challenge/response flow. The first request isn't
authenticated so the server returns 401.1. The next request passes an
authentication token and the server returns 200.

This is the code I'm using to initialize the webservice. It's inside a
static class and I re-use the webservice throughout the application:

MyService _service = new MyService();
NetworkCredential myCred = new NetworkCredential(UserName, Password,
Domain);
CredentialCache myCache = new CredentialCache();
myCache.Add(new Uri(_service.Url), "NTLM", myCred);

_service.Credentials = myCache;
_service.PreAuthenticate = true;

I don't know if the PreAuthenticate property has anything to do with it. As
far as I see it, this property makes sure that the WWW-authenticate is sent
on all subsequent requests after the first one.

The only thing that works is exit the application and restart again.

So my question is, has anyone come across this issue? Any explanation why
the server suddenly returns 401.2 messages?

Thanks in advance,
 

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