WCF 请求适用于 Windows 窗体,但不适用于 Windows 服务 [英] WCF request works from windows forms but not windows service

查看:44
本文介绍了WCF 请求适用于 Windows 窗体,但不适用于 Windows 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WCF 服务作为 Windows 服务安装,配置为使用 NETTCP 绑定.除了导入服务定义、制作客户端和调用函数之外,我没有做任何特别的事情.

My WCF service is installed as a windows service configured to use NETTCP binding. I did not do anything special other than importing the service definition, making the client and calling the function.

当我从 windows 窗体应用程序 调用 WCF 服务时,我能够正常发送请求.但是当我在作为本地系统运行的 Windows 服务中运行相同的代码时,我在服务跟踪文件中收到服务不允许您匿名登录."警告和套接字连接中止".

When I call the WCF service from a windows forms application, I am able to send requests normally. But when I run the same code inside a windows service running as Local System, I get "The service does not allow you to log on anonymously." warning and a "socket connection aborted" in the service trace file.

有人可以告诉我从身份验证的角度从 Windows 服务而不是 Windows 窗体发出 WCF 请求时我还需要注意什么吗?

Can someone give me an idea of what else I need to take care of when making WCF requests from a windows service instead of windows forms from an authentication perspective?

推荐答案

来自 这个 MSDN 页面,看起来任何使用本地系统帐户提供服务的 WCF 客户端都将被匿名 NTLM 处理.这就是解决我的问题的原因 - 更改服务帐户.我仍然不知道 windows 窗体使用什么帐户,但没关系.

From this MSDN page, it looks like any WCF client that uses Local System account for the service will be treated with Anonymous NTLM. That's what solved my problem -changing the account for the service. I still don't know what account a windows forms uses, but that's ok.

这篇关于WCF 请求适用于 Windows 窗体,但不适用于 Windows 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆