在 Windows 2008 上的服务器上运行 IIS 5.0 下的 WCF 客户端时出现错误

StackOverflow https://stackoverflow.com/questions/897718

  •  23-08-2019
  •  | 
  •  

我有一个在 Windows 2008 计算机上的 IIS 7 下运行的 .Net 3.5 SP1 WCF 服务。当我尝试从在 IIS 5.0 (Windows XP) .Net 3.5 SP1 下运行的 IIS 托管 WCF 服务连接到此服务时,出现以下错误:

令牌提供者无法获取目标的令牌: http://(网址 对于 WCF 服务)

我构建了一个简单的控制台应用程序,可以使用完全相同的配置成功连接到 WCF 服务。我还构建了一个托管在 WebDev 服务器(Visual Studio 2008 附带的 ASP.Net 服务器)下的简单 Web 应用程序,它能够成功连接到 WCF 服务。当我在 IIS (Windows XP) 中配置虚拟目录以指向与 WebDev 服务器相同的目录时,出现以下错误:

安全包中没有可用的凭据

但是,如果我将 web.config 设置为使用我的登录凭据打开模拟,则它可以正常工作。出于显而易见的原因,这不是一个好的长期解决方案。我注意到 IIS 和 WebDev 服务器之间的一个区别是每个进程运行的用户。IIS 在 ASPNet 帐户下运行,WebDev 在我的帐户下运行。

以下是客户端上 WCF 部分的配置:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding name="FABindings" maxReceivedMessageSize="2147483647">
      <readerQuotas maxStringContentLength="300000"/>
      <security mode="Message">
        <message clientCredentialType="Windows" negotiateServiceCredential="false" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://<server url>/FinancialAggregator/v3/Services/FAService.svc"
      binding="wsHttpBinding" bindingConfiguration="FABindings"
      contract="ServiceReference1.IFilteredService" name="FAServiceEndpoint">
    <identity>
      <servicePrincipalName value="<UsernameRunningTheAppPoolOnW2k8>" />
    </identity>
  </endpoint>
</client>  

这是服务器配置(根据要求):

  <system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding" maxReceivedMessageSize="2147483647">
      <security mode="Message">
        <message establishSecurityContext="false" negotiateServiceCredential="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="mexBehavior" name="FCSAmerica.Financial.Aggregator.Service.FilteredService">
    <endpoint name="FAServiceEndpoint" address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="FCSAmerica.Financial.Aggregator.Service.IFilteredService">
    </endpoint>
  </service>
</services>

关于此错误的原因有什么想法吗?

谢谢!

有帮助吗?

解决方案 2

我想这个问题最终的答案是简单地升级到OS,可以让你设置一个应用程序池,这是我很久以前做过的身份。

感谢您的考虑。

马特

其他提示

当您通过 IIS 访问服务时,使用 impersonate = false,则使用 ASPnet 帐户访问 Windows 2008 计算机上的服务。

ASPnet 帐户是本地帐户,因此在 2008 计算机上没有权限。

有 3 种方法可以解决这个问题:

  • 允许匿名访问 Windows 2008 计算机上的服务
  • 使用 impersonate = true (就像你一样)
  • 将应用程序池的标识从 aspnet 更改为具有所需访问权限的域帐户。
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top