【发布时间】:2012-02-01 08:12:08
【问题描述】:
我有一个相当简单的 WCF 自托管服务,它使用 WSHttpBinding 只是拒绝工作。如果服务和客户端在同一台机器上运行,则没有问题,但是一旦我将服务移动到 window-server 2008,客户端的通信尝试就会失败
例外
[System.ServiceModel.Security.SecurityNegotiationException] {"目标 'http://hvw-svr-01/SIT' 的 SOAP 安全协商失败。请参阅内部更多细节的例外。"}
内部异常
[System.ComponentModel.Win32Exception] {“安全支持提供程序接口 (SSPI) 协商失败。服务器可能未在身份为 'host/hvw-svr-01' 的帐户中运行。如果服务器在服务帐户(例如网络服务),将帐户的 ServicePrincipalName 指定为服务器的 EndpointAddress 中的身份。如果服务器在用户帐户中运行,请将帐户的 UserPrincipalName 指定为服务器的 EndpointAddress 中的身份。"}
由于它是自托管服务,我想我需要指定 UserPrincipalName,但无论我为该属性尝试什么,它都不起作用。
- 域\用户名
- 域@用户名
- 主机/本地主机
- 主机/hvw-svr-01
- ...等等
还尝试了不同的用户帐户,包括内置的管理员。如果我尝试 BasicHttpBinding 而不是 WSHttpBinding 一切都按预期工作。我在 google(和 stackoverflow)上阅读了大量关于该问题的文章,但我仍然无法弄清楚问题是什么以及如何指定该身份。
编辑:Service App.Config
<system.serviceModel>
<services>
<service name="SIT.Communication.Gate">
<host>
<baseAddresses>
<add baseAddress="http://localhost:2323/SIT" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="SIT.Core.IGate">
<identity>
<dns value="localhost"/>
<userPrincipalName value="XZDom\DGrain"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
编辑:客户端本身基本上就是这个代码片段
ChannelFactory<IGate> sitFactory = new ChannelFactory<IGate>(new WSHttpBinding(), new EndpointAddress("http://hvw-svr-01:2323/SIT")); IGate sitProxy = sitFactory.CreateChannel(); bool pong = sitProxy.Ping(); <------ throws exception
【问题讨论】:
-
您可以发布您用于托管服务的配置吗?
-
如果您从配置中完全删除
idenity部分,它会起作用吗? -
不行,已经试过了(在stackoverflow上的某处阅读)
-
机器是否在同一个域中?
-
您也可以发布客户端的配置,以便我们了解客户端的期望吗?
标签: c# asp.net .net vb.net wcf