简体   繁体   English

从Windows服务调用Web服务

[英]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. 我试图从Windows服务中调用Web服务。 The web service is secured (using Windows authentication). Web服务是安全的(使用Windows身份验证)。 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. 运行Windows服务的帐户确实有权调用Web服务,但我无法弄清楚如何获取这些凭据并将其发送到Web服务。 The web service is WCF and is hosted on the same machine (in IIS) as the windows service. Web服务是WCF,并与Windows服务托管在同一台计算机上(在IIS中)。

You should be able to use something like this: 你应该可以使用这样的东西:

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

Have you tried enabling integrated authentication (NTLM) for IIS? 您是否尝试为IIS启用集成身份验证(NTLM)? In my view that should allow you to call web service if the windows service user account has rights to invoke the service. 在我看来,如果Windows服务用户帐户有权调用该服务,那么应该允许您调用Web服务。 you need not explicitly extract credentials. 您无需显式提取凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM