微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我最近在我们的开发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团队将继续调查此问题以进行修复.在我们调查时,您可以通过在配置文件中显式配置webHttp端点来解决此问题.服务将像以前一样行为.尝试遵循这些简单的步骤.

(我将您在本文中发布的配置文件作为起点)

>注释掉< standardEndpoints>您的配置文件中的标记

<! – < standardEndpoints>
      < webHttpEndpoint>
        < standardEndpoint name =“”helpEnabled =“true”automaticFormatSelectionEnabled =“true”/>
      < / webHttpEndpoint>
    < / standardEndpoints> – >
>将此端点行为添加到列表中,如下所示:

<行为>
        < endpointBehaviors>
  < behavior name =“REST”>
      < webHttp helpEnabled =“true”automaticFormatSelectionEnabled =“true”/>
   < /行为>
   < / endpointBehaviors>
< /行为>
>在配置文件中明确配置服务端点,如下所示.对于突出显示属性值,分别替换服务类型名称和合同名称(注意:如果没有为服务定义合同,则在contract =“”中也插入服务类型名称)

<服务>      < service name =“WcfRestService1.Service1”>               < endpoint address =“”binding =“webHttpBinding”contract =“WcfRestService1.Service1”behaviorConfiguration =“REST”/>      < /服务>< /服务>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐