【发布时间】:2016-12-28 14:20:46
【问题描述】:
我有一个带有 CSLA 的 WCF 项目,我已经在我的 IIS 服务器中发布了这个服务和 MVC 应用程序,但是从 Web 应用程序调用服务时它抛出了一个错误
System.ServiceModel.Security.SecurityNegotiationException:调用者未经服务验证。 ---> System.ServiceModel.FaultException: 由于身份验证失败,无法满足对安全令牌的请求。
这是我的服务 web.config
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Csla.Server.Hosts.WcfPortal" behaviorConfiguration="returnFaults">
<endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IWcfPortal" contract="Csla.Server.Hosts.IWcfPortal" />
</service>
<service name="Csla.Server.Hosts.Mobile.WcfPortal" behaviorConfiguration="returnFaults">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal" contract="Csla.Server.Hosts.Mobile.IWcfPortal" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647" maxDepth="2147483647" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647">
<readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647" maxDepth="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我已经像这样在我的 MVC web.config 中使用了这个服务。
<add key="CslaAuthentication" value="Csla" />
<add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla" />
<add key="CslaDataPortalUrl" value="http://www.someurl.net/WcfFullPortal.svc" />
然后在我直接从我的服务项目中调用服务后,它工作正常。
<add key="CslaDataPortalUrl" value="http://localhost:11170/WcfFullPortal.svc" />
还尝试使用已发布的 IP 地址,也可以正常工作
<add key="CslaDataPortalUrl" value="http://10.4.56.75/WcfFullPortal.svc" />
只有当我使用已发布的主机名 (http://www.someurl.net/WcfFullPortal.svc) 时才会出现问题。我已经通过正常工作的浏览器打开了这个 URL。
【问题讨论】:
标签: asp.net-mvc wcf csla