WCF - .Net 4.5 安装后的端点冲突

标签 wcf web-config .net-4.5

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

绑定(bind)实例已与监听 URI 相关联。如果两个端点想要共享同一个 ListenUri,它们也必须共享同一个绑定(bind)对象实例。两个冲突的端点要么在 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 会尝试为您创建绑定(bind)和端点,因此它们不需要在 web.config 中。所以我想知道这部分是否由 WCF 自动构建并且不需要。还是我的想法不正确?
谢谢!

最佳答案

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

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

  • 注释掉配置文件中的 标记:

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

    <行为>
    <端点行为>
    <行为名称="REST">



  • 像这样在配置文件中显式配置您的服务端点。对于突出显示的属性值,分别替换您的服务类型名称和契约(Contract)名称(注意:如果您没有为服务定义契约(Contract),则在契约(Contract) =“”中插入服务类型名称)

    <服务>
    <服务名称="WcfRestService1.Service1">


  • 关于WCF - .Net 4.5 安装后的端点冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12643113/

    相关文章:

    c# - 带有自定义连接字符串的 EF 6 程序化迁移

    c# - 如何使用 FluentMigrator 删除列?

    c# - 伪造键盘或鼠标事件

    wcf - 在 SOA 应用程序中使用 DTO 的最佳方式是什么?

    c# - 为什么更改连接字符串会引发只读错误?

    c# - WCF Web 服务的响应大小限制

    asp.net-mvc - ID4175 : The issuer of the security token was not recognized by the IssuerNameRegistry

    asp.net - 是否可以在不结束所有用户 session 的情况下更改web.config?

    WCF:使用带有证书吊销列表检查的安全消息

    c# - Catch-22 阻止了 WIF 保护的流式 TCP WCF 服务;毁了我的圣诞节,心理健康