none
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection RRS feed

  • Question

  • Hi,
     
    Please I'm new to WCF world and I need help.
     
    I have created WCF project library which contain two services (service1, service2). I couldn't configure their end point successfully. I'm getting the following error message

    This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection

    <?xml version="1.0"?>
    <configuration>
      <connectionStrings>
        <add name="SharafConnectionString" connectionString="Data Source=(local);Initial Catalog=Sharaf;Integrated Security=False;User id=User;password=111" providerName="System.Data.SqlClient"/>
      </connectionStrings>
      <!--<system.web>
        <compilation defaultLanguage="VB" debug="true" />
      </system.web>-->
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true">
            <listeners>
              <add name="traceListener"
                  type="System.Diagnostics.XmlWriterTraceListener"
                  initializeData="c:\log\Traces.svclog"  />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>
      <!-- When deploying the service library project, the content of the config file must be added to the host's 
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="ServicesLibarary.Service1" behaviorConfiguration="ServiceBehavior">
            <endpoint address="WSHttpEP" 
                      binding="wsHttpBinding" 
                      bindingConfiguration="HttpBinding"                 
                      contract="ServicesLibarary.IService1" />
            <endpoint address="mex" 
                      binding="mexHttpBinding" 
                      contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost/ServicesLibarary/Service1/" />
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/ServicesLibarary/Service1/" />
              </baseAddresses>
            </host>
          </service>
          <service name="ServicesLibarary.Service2" behaviorConfiguration="ServiceBehavior">
            <endpoint address="WSHttpEP"
                      binding="wsHttpBinding"
                      bindingConfiguration="HttpBinding"
                      contract="ServicesLibarary.IService2" />
            <endpoint address="mex" 
                      binding="mexHttpBinding" 
                      contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost/ServicesLibarary/Service2/" />
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/ServicesLibarary/Service2/" />
              </baseAddresses>
            </host>
          </service>      
        </services>
        <bindings>
          <wsHttpBinding>
            <binding name="HttpBinding"
                     allowCookies="true"
                     maxBufferPoolSize="2147483647"
                     maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647"
                            maxStringContentLength="2147483647"
                            maxArrayLength="2147483647"
                            maxBytesPerRead="2147483647"
                            maxNameTableCharCount="2147483647" />
              <security mode="Transport">
                <transport clientCredentialType = "Windows" />
              </security>
              <reliableSession enabled="true" />
            </binding>
          </wsHttpBinding>      
        </bindings>
        
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
              <!-- To avoid disclosing metadata information, 
              set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="True"/>
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="True"/>
            </behavior>
          </serviceBehaviors>      
        </behaviors>
      </system.serviceModel>
    </configuration>

     

    Sunday, December 25, 2011 2:19 PM

Answers

  • For this case you also need to have one base address for the HTTPS protocol. You can only have one base address for each protocol, but you need a base address for each protocol your endpoints are using. Since your endpoint uses the security mode "Transport", that means that the endpoint should use HTTPS (instead of HTTP), so you need a base address for that as well.


    Carlos Figueira
    • Marked as answer by Yi-Lun Luo Friday, December 30, 2011 8:51 AM
    Sunday, December 25, 2011 10:54 PM
    Moderator

All replies

  • For each of your services, you have two base addresses for HTTP (http://localhost/ServiceLibrary and http://localhost:8732/DesignTimeAddress/...). As the error explains, you can only have one of those, otherwise WCF will not know which one to pick for the endpoints.

        <services>
          <service name="ServicesLibarary.Service1" behaviorConfiguration="ServiceBehavior">
            <endpoint address="WSHttpEP" 
                      binding="wsHttpBinding" 
                      bindingConfiguration="HttpBinding"                 
                      contract="ServicesLibarary.IService1" />
            <endpoint address="mex" 
                      binding="mexHttpBinding" 
                      contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost/ServicesLibarary/Service1/" />
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/ServicesLibarary/Service1/" />
              </baseAddresses>
            </host>
          </service>
          <service name="ServicesLibarary.Service2" behaviorConfiguration="ServiceBehavior">
            <endpoint address="WSHttpEP"
                      binding="wsHttpBinding"
                      bindingConfiguration="HttpBinding"
                      contract="ServicesLibarary.IService2" />
            <endpoint address="mex" 
                      binding="mexHttpBinding" 
                      contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost/ServicesLibarary/Service2/" />
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/ServicesLibarary/Service2/" />
              </baseAddresses>
            </host>
          </service>      
        </services>
    


    Carlos Figueira
    Sunday, December 25, 2011 6:01 PM
    Moderator
  • I did remove one of them "http://design_time" but I'm getting another error

    Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].

     

    so for each service I have two end points and one baseaddress for each baseaddress which I seen in some WCF services implementation but the baseaddress is unique using a port number. I don't know I'm really confused and I don't know how to fix this issue.

    Thanks 

    Sunday, December 25, 2011 8:21 PM
  • For this case you also need to have one base address for the HTTPS protocol. You can only have one base address for each protocol, but you need a base address for each protocol your endpoints are using. Since your endpoint uses the security mode "Transport", that means that the endpoint should use HTTPS (instead of HTTP), so you need a base address for that as well.


    Carlos Figueira
    • Marked as answer by Yi-Lun Luo Friday, December 30, 2011 8:51 AM
    Sunday, December 25, 2011 10:54 PM
    Moderator