【问题标题】:WCF - Conflicting endpoints after .Net 4.5 installationWCF - .Net 4.5 安装后的端点冲突
【发布时间】:2012-09-28 15:39:54
【问题描述】:

我最近在我们的开发 Web 服务器上安装了 4.5 框架,该服务器在 Windows Server 2008 上运行 IIS 7.5。安装后,两个 Web 服务开始出现相同的错误。这些 Web 服务是使用 MS REST Starter Kit 构建的。这是我遇到的错误。

一个绑定实例已经与监听 URI 相关联。如果两个端点想要共享同一个 ListenUri,它们也必须共享同一个绑定对象实例。两个冲突的端点要么在 AddServiceEndpoint() 调用中指定,要么在配置文件中指定,要么在 AddServiceEndpoint() 和 config 的组合中指定。

这是我们配置文件的 system.service 模型部分的副本。

<system.serviceModel>
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />  
    <bindings>
      <webHttpBinding>
        <binding>
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
      <wsHttpBinding>
        <binding name="EnterpriseIdentityBinding" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    <client>
      <endpoint address="https://betaapps/EnterpriseIdentity/V1/UserService.svc"
        binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
        contract="UserServiceWCF.IUserService" name="wsSecureUsers" />
      <endpoint address="https://betaapps/EnterpriseIdentity/V1/RoleService.svc"
        binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
        contract="RoleServiceWCF.IRoleService" name="wsSecureRoles" />
    </client>

    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceAuthorization principalPermissionMode="Custom">
            <authorizationPolicies>
              <add policyType="Hsmv.Web.Security.IdentityModel.HttpContextWithRolesPolicy, Hsmv.Web.Security" />
            </authorizationPolicies>
          </serviceAuthorization>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

知道为什么安装 .Net 4.5 后会出现此错误吗?

我想补充一点,我尝试删除此部分,没有它也可以工作。

<webHttpBinding>
        <binding>
          <security mode="Transport" />
        </binding>
</webHttpBinding>

我使用它是因为该服务在 ssl 上运行。我听说 WCF 4.5 会尝试为您创建绑定和端点,因此它们不需要在 web.config 中。所以我想知道这部分是否由 WCF 自动构建并且不需要。还是我的想法不正确? 谢谢!

【问题讨论】:

  • 感谢您报告此问题。我来自 WCF 团队。我们正在调查这个问题。

标签: wcf web-config .net-4.5


【解决方案1】:

我来自 WCF 团队。感谢您报告此问题。 WCF 团队将继续调查此问题以进行修复。在我们进行调查时,您可以通过在配置文件中显式配置 webHttp 端点来解决此问题。服务将与以前一样的行为相同。尝试遵循这些简单的步骤。

(我以你在这篇文章中发布的配置文件为起点)

  1. 注释掉配置文件中的 标签:


  2. 将此端点行为添加到您的列表中,如下所示:





    行为>

    行为>

  3. 像这样在配置文件中显式配置您的服务端点。对于突出显示的属性值,分别替换您的服务类型名称和合同名称(注意:如果您没有为服务定义合同,请在 contract="" 中插入服务类型名称)




    服务>
    服务>

【讨论】:

    【解决方案2】:

    就我而言,一旦我从 web.config 中删除 &lt;security/&gt; 标记,问题就解决了。我将其设置为“无”,因此这可能不适用于您的特定情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-26
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      • 2013-01-12
      • 1970-01-01
      • 1970-01-01
      • 2022-12-28
      相关资源
      最近更新 更多