views:

186

answers:

4

A windows service was developed and runs on a 32 bit machine. It communicates to the Project Web Access web service. Now, the service was moved to the same computer as the Project Web Access web service. The code fails and I recieve this error:

System.Net.WebException: The request failed with HTTP status 401: Unauthorized. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at ProjToolService.ProjectWebSvc.Project.ReadProject(Guid projectUid, DataStoreEnum dataStore)
at ProjToolService.Queue.AssignResource(Guid queueId, Guid projectId, Guid taskId, Guid resourceId, Guid assignmentId)

It may not be the 32bit vs 64bit, but I have no other ideas.

The target platform is x86, but it also failed using AnyCPU. I tried using DefaultCredentials and System.net.CredentialCache.DefaultNetworkCredential as well.

+2  A: 

401 is a HTTP status, so it shouldn't have anything to do with the 32 vs 64 bit. I would check and make sure that the web service is setup using the correct crednentials (especially if you are planning on using anonymous access).

If I remember correctly the DefaultNetworkCredential pulls the account running the service, so I would check to make sure the account for the service you are using has the appropriate authorities to access the web service. The easy way to check this is give the account running the service administrative access to the machine (then take it away when you're done). if it works, then it is a permissions problem. If not, then you know it's something else.

To give the account rights go to Administrative Tools -- > Computer Management -- >Local Users And Groups -- > Groups. Add the Network User to the appropriate group (like I said I would start with admin and work my way down.)

Kevin
my service is running using a network user. i tried DefaultNetorkCredential and it didnt work. not sure how to grant or know if they user is the administrator of the machine tho >.>
Marlon
A: 

What user is your service running as? Keep in mind Local User, etc. don't run when the box isn't logged into, which servers generally aren't. Network User might work.

tsilb
my service is running using a network user. i tried DefaultNetorkCredential and it didnt work. not sure how to grant or know if they user is the administrator of the machine tho >.>
Marlon
A: 

The security settings on the Win2003 are much more conservative than in WinXP, especially in network access. You might be better served looking in your webservice and system logs for "access denied" errors, and make sure your service (with its exact name, up to the ? in the URL) is allowed access to serve requests.

scraimer
A: 

Thanks for all the help & attention but i finally discovered the problem. The problem was the issue of the win service running locally with the web service. This problem was specific to the Windows server 2003 operating system. to resolve the problem i had to create a New Value in the registry editor called DisableLoopbackCheck, and set it to 1.

Marlon