【发布时间】:2011-01-24 13:25:07
【问题描述】:
我有一个托管在共享环境中的 WCF 服务(我们从一家网络托管公司租用空间,但我们有一个专用的应用程序池。),我有一个调用 wcf 服务的 asp.net Web 应用程序。这两个项目都是 .NET 4 项目。
如果我从 VS2010 运行我的 Web 应用程序,我可以轻松地进行 wcf 调用。但是,如果我在该共享环境中发布网站并从那里进行 wcf 调用,则会出现异常。
异常详情:
[FaultException: 由于身份验证失败,无法满足对安全令牌的请求。] System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(消息消息,端点地址目标)+5499790 System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState) +49
[SecurityNegotiationException: 调用者未经服务验证。] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9464367 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型) +345
我也在本地机器上发布网站,它也可以。
这是我在服务器端的配置:
<wsHttpBinding>
<binding name="wsHttpBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
客户端代码:
factory.Credentials.Windows.Username = "user";
factory.Credentials.Windows.Password = "psw";
factory = new ChannelFactory<IService>(binding, serviceAddress);
factory.Open();
service = factory.CreateChannel();
我想使用 wsHttpBinding 而不是 basicHttpBinding,而且我确实需要一些安全性,所以我不想将安全模式设置为 None。
Windows 2008 R2 上的 IIS 版本为 7,并设置为允许匿名身份验证。 Asp.net 模拟已禁用。
我不认为这些设置有什么问题,因为如果我从 VS2010 运行网站项目,它确实可以工作。
感谢您的帮助。
小苏
【问题讨论】:
-
双方安全模式:
标签: wcf