WCF REST:(C# 4.0 模板)通过 Windows 身份验证进行保护并在 Windows 服务中托管?
我正在尝试了解如何使用 Windows 身份验证(Active Directory)来保护我的 Web 服务。我正在使用为 c# 4.0(vs 2010)提供的“新”模板,目前有这个模板,但我需要将它托管在 Windows 服务中 - 这可能吗?
我认为 WCF Rest clientCredentialType ="Windows" 实际上使用 IIS 来提供这种类型的安全性?
我在互联网上搜索并找到了许多使用 C# 3.5 的示例,但没有找到为 vs 2010 C# 4.0 提供的用于创建休息服务的新模板。W
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true"
automaticFormatSelectionEnabled="true">
<security mode="">
<transport clientCredentialType = "Windows" />
</security>
I am trying to find out how to secure my web services with Windows Authentication (Active Directory). I am using the "NEW" templates provided for c# 4.0 (vs 2010) and currently have this but i need to host it in a windows service - is this possible?
I thought the WCF Rest clientCredentialType ="Windows" actually uses IIS to provide this type of security?
I have searched the internet and found many examples with C# 3.5 but none for the new template provided to vs 2010 C# 4.0 to create a rest service.W
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true"
automaticFormatSelectionEnabled="true">
<security mode="">
<transport clientCredentialType = "Windows" />
</security>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VS 2010 中的新模板称为 WCF REST 服务应用程序。它使用
ServiceRoute
公开的单个预定义 REST 服务创建 Web 应用程序。此应用程序类型依赖于启用了AspNetCompatibility
的 IIS 托管(或通常的 Web 服务器托管)。它不能直接转换为windows服务中的托管。某些 WCF REST 功能(WebRouting、输出 chache 配置文件)依赖于AspNetCompatibility
,这通常在 Web 服务器之外不可用。但如果您不需要这些功能,您可以轻松地在 Windows 服务中托管 WCF REST 服务。您可以将新项目启动为 WCF 服务库,将第二个项目启动为 Windows 服务来托管库中的服务。
您不需要 .NET 4.0 中的任何新模板来定义具有 Windows 安全性的 WebHttp 端点。这就足够了:
通过在
binding
元素中省略name
,您可以定义默认的webHttpBinding
配置。每次使用WebHttpBinding
定义端点时,都会使用此配置。StandardEnpoint
是 WCF 4.0 的新功能。在这种情况下也可以使用它,但不是必需的。New template in VS 2010 is called WCF REST Service application. It creates web application with single predefined REST service which is exposed by
ServiceRoute
. This application type is dependent on IIS hosting (or web server hosting generally) withAspNetCompatibility
turned on. It can't be directly converted into hosting in windows service. Some WCF REST features (WebRouting, Output chache profiles) are dependent onAspNetCompatibility
which is normally not available outside of web server.But If you don't need those features you can easily host WCF REST services in Windows service. You can start new project as WCF service library and second project as Windows service to host services from library.
You don't need any new template from .NET 4.0 to define WebHttp endpoint with windows security. This is enough:
By omitting
name
inbinding
element you are defining defaultwebHttpBinding
configuration. Each time you define endpoint withWebHttpBinding
this configuration will be used.StandardEnpoint
is new feature of WCF 4.0. It can be also used for in this case but it is not necessary.