none
Error calling WCF Service Using HTTPS vs. HTTP A binding instance has already been associated to listen URI RRS feed

  • Question

  • Hi,

        We have a WCF Service setup in IIS which works fine with HTTP but when we used the URI as HTTPS that fails.  We have a separate site for the HTTPS and we know the Port is open.  I believe the issue is with the Web.Config but having issues troubleshooting.  

    The Error Message: 

    A binding instance has already been associated to listen URI 'http://<server/fqdn>.com:8111/<servicename>.svc'. 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.

    The port listed above is example only but that is associated to the HTTP.  

    In the web.config:

        <protocolMapping>
          <add scheme="https" binding="wsHttpBinding"/>
          <add scheme="http" binding="basicHttpBinding"/>
        </protocolMapping>

     <service name="<service name>r" behaviorConfiguration="DefaultBehaviorConfig">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHTTPBindingConfig" contract="<servicename>">
            </endpoint>
     </service>

    Questions:

    1. Does the bingding basicHttpBinding support HTTPS  Or should it be wsHttpBinding?

    2. I don't think we need seperate entries in the Web.config for HTTP and HTTPS but can you confirm?

    Any other ideas how to troubleshoot?

    Thanks

    Mark.

    Wednesday, July 24, 2019 9:41 PM

All replies

  • Hi,

    I could not reproduce you problem according to the above code snippets. If we want to add the support for HTTPS protocol, the only thing we need to do is add the endpoint with transport security.
    Please consider using the below configuration. It supports both http and https protocol as long as we specify http base address and https base address in site binding module.

    <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="mybinding">
              <security mode="Transport">
                <transport clientCredentialType="None"></transport>
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        <protocolMapping>
          <add scheme="https" binding="basicHttpBinding" bindingConfiguration="mybinding"/>
          <add scheme="http" binding="basicHttpBinding"/>
        </protocolMapping>
      </system.serviceModel>

    When calling the service by adding service reference, it will generate the both http and https endpoint on the client-side. Besides, I use ProtocolMapping feature to simplify the configuration.
    About Protocol Mapping in WCF4.5, please refer to the below link.
    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/protocolmapping
    https://docs.microsoft.com/en-us/dotnet/framework/wcf/whats-new

    Feel free to let me know if the problem still exists.

    Best Regards

    Abraham


    Thursday, July 25, 2019 9:09 AM
    Moderator