WCF - Conflicting endpoints after .Net 4.5 installation

半世苍凉 提交于 2021-02-18 03:24:28

问题


I'm recently installed the 4.5 framework on our development web server which runs IIS 7.5 on Windows Server 2008. After installation, two web services started having the same error. These web services were built using the MS REST Starter Kit. Here is the error I'm getting.

A binding instance has already been associated to listen URI . If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.

Here is a copy of the system.service model section of our config file.

<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>

Any idea why this error would occur after installing .Net 4.5?

I would like to add that I tried removing this section and it does work without it.

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

I use this because this service runs on ssl. I heard that WCF 4.5 tries to create bindings and endpoints for you so they don't need to be in the web.config. So I wondered if this section is being automatically built by WCF and is not needed. Or is my thinking incorrect? Thanks!


回答1:


I am from WCF team. Thanks for reporting this issue. WCF team will continue to investigate this issue for fix. While we investigate you can work around this by explicitly configuring a webHttp endpoint in your configuration file. Service will be the same by behavior like before. Try to follow these simple steps.

(I am taking the configuration file that you have published in this post as a starting point)

  1. Comment out the <standardEndpoints> tag in your configuration file:

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

  2. Add this end point behavior to your list like this:

    <behaviors>
    <endpointBehaviors>
    <behavior name="REST">
    <webHttp helpEnabled="true" automaticFormatSelectionEnabled="true" />
    </behavior>
    </endpointBehaviors>
    </behaviors>

  3. Explicitly configure your service endpoint in the config file like this. For highlighted attribute values substitute your service type name and contract name respectively (Note: if you don’t have a contract defined for service, then insert service type name in contract=”” too)

    <services>
    <service name="WcfRestService1.Service1">
    <endpoint address="" binding="webHttpBinding" contract="WcfRestService1.Service1" behaviorConfiguration="REST" />
    </service>
    </services>




回答2:


In my case, the problem solved once I removed the <security/> tag from the web.config. I had it setted to "none", so this may not apply to your particular case.



来源:https://stackoverflow.com/questions/12643113/wcf-conflicting-endpoints-after-net-4-5-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!