Arun
Arun

Reputation: 800

Calling a web service from a windows service

I'm sure there's an elegant solution to the problem but I just can't get my head around it. I am trying to call a web service from within a Windows service. The web service is secured (using Windows authentication). The account that the windows service runs under does have the rights to call the web service but I can't figure out how to get those credentials and send them off to the web service. The web service is WCF and is hosted on the same machine (in IIS) as the windows service.

Upvotes: 3

Views: 4856

Answers (2)

Rutesh Makhijani
Rutesh Makhijani

Reputation: 17225

Have you tried enabling integrated authentication (NTLM) for IIS? In my view that should allow you to call web service if the windows service user account has rights to invoke the service. you need not explicitly extract credentials.

Upvotes: 0

Steven Robbins
Steven Robbins

Reputation: 26599

You should be able to use something like this:

var myService = new myThing.Service();
myService.Credentials = System.Net.CredentialCache.DefaultCredentials;

Upvotes: 6

Related Questions