Microsoft Developer Network > Página principal de foros > Windows Communication Foundation > There can be at most one address per scheme in this collection.
Formular una preguntaFormular una pregunta
 

RespondidaThere can be at most one address per scheme in this collection.

  • jueves, 08 de febrero de 2007 21:45Mark A. Richman Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    When hosting my .svc in IIS, I get the following error:

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

    I know this is caused by sites that have multiple bindings. In my case, I am a web hoster and have sites with multiple host headers per site.

    Is there any way to override this behavior in web.config? I've tried the following with no effect:

    <host>
      <baseAddresses>
        <clear/>
        <add baseAddress="
    http://mydomain.com" />
      </baseAddresses>
    </host>

    Any ideas for how to make this work without forcing my customers to modify their source?

    Thanks,
    Mark

Respuestas

  • jueves, 22 de febrero de 2007 17:06Wenlong Dong Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida

    Hi Mark,

    Unfortunately the behavior is by design. WCF does not support multiple IIS bindings for the same protocol (here it is HTTP) for the same web site. This is for simplicity, especially it did not seem to be an important scenario. Is this a very important scenario for you? Can't you host different services in different web sites (with different ports of course)? If this does block you, we may think about revisiting this issue again.

    Thanks,

    Wenlong 

Todas las respuestas

  • miércoles, 14 de febrero de 2007 4:44Jeff Cao Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    Hi, Mark:

    Are you using reliable messaging?  You might be hitting this bug:

    http://blogs.msdn.com/drnick/archive/2006/12/05/incompatible-addressing-with-reliable-messaging.aspx.

    The workaround is that if you need to have multiple service endpoints that both use reliable messaging but have different message addressing versions, then you should create a new application domain to keep the endpoints separate.

    Hope this helps.

  • jueves, 22 de febrero de 2007 14:36Bing M_ Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    I got the same problem. Could you please tell me where shall I put the <host> section ? I tried the following, this is the only place I don't get compile error. However, the program can not recognize the second and third services.

    <system.serviceModel>
      <services>

      <service name="OpusEdge.TestModel.Service1" behaviorConfiguration="returnFaults">
        <host>
         <baseAddresses>
          <add baseAddress="http://localhost:2111/WCFService" />
         </baseAddresses>
        </host>

        <endpoint contract="OpusEdge.TestModel.IService1" binding="wsHttpBinding"/>
       </service>
       <service name="OpusEdge.TestModel.Service2" behaviorConfiguration="returnFaults">
        <endpoint contract="OpusEdge.TestModel.IService2" binding="wsHttpBinding"/>
       </service>
       <service name="OpusEdge.TestModel.Service3" behaviorConfiguration="returnFaults">
        <endpoint contract="OpusEdge.TestModel.IService3" binding="wsHttpBinding"/>
       </service>
      </services>
      <behaviors>
       <serviceBehaviors>
        <behavior name="returnFaults" >
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
       </serviceBehaviors>
      </behaviors>
     </system.serviceModel>

    Thanks,

    Bing

     

     Mark A. Richman wrote:

    When hosting my .svc in IIS, I get the following error:

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

    I know this is caused by sites that have multiple bindings. In my case, I am a web hoster and have sites with multiple host headers per site.

    Is there any way to override this behavior in web.config? I've tried the following with no effect:

    <host>
      <baseAddresses>
        <clear/>
        <add baseAddress="
    http://mydomain.com" />
      </baseAddresses>
    </host>

    Any ideas for how to make this work without forcing my customers to modify their source?

    Thanks,
    Mark

  • jueves, 22 de febrero de 2007 17:06Wenlong Dong Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida

    Hi Mark,

    Unfortunately the behavior is by design. WCF does not support multiple IIS bindings for the same protocol (here it is HTTP) for the same web site. This is for simplicity, especially it did not seem to be an important scenario. Is this a very important scenario for you? Can't you host different services in different web sites (with different ports of course)? If this does block you, we may think about revisiting this issue again.

    Thanks,

    Wenlong 

  • viernes, 23 de febrero de 2007 16:27KevinBurton Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
     Wenlong Dong wrote:

    Hi Mark,

    Unfortunately the behavior is by design. WCF does not support multiple IIS bindings for the same protocol (here it is HTTP) for the same web site. This is for simplicity, especially it did not seem to be an important scenario. Is this a very important scenario for you? Can't you host different services in different web sites (with different ports of course)? If this does block you, we may think about revisiting this issue again.

    Thanks,

    Wenlong 

    I don't have multiple bindings but I am getting this same error. Let me explain. When I copy the assemblies and the .svc to the remote machine I get an error that Microsoft.CommerceServer.Internal.ContentListHelper.dll could not be loaded (I am developing on a 32 bit OS and copying to a 64 bit OS). Looking on the remote computer I find another assembly with the same name and replaced it. The new files size was 91KB and the old one was 71KB. I am assuming that the difference in size is because of the 64 bit OS. With the newly copied file I get the error that is described in this thread. Is this related to the 64 bit OS or is there another problem?

    Thank you.

    Kevin

  • miércoles, 28 de febrero de 2007 3:15Mark A. Richman Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    This is quite important, since I'm a web hoster. Each of my customers' sites are provisioned with serveral ServerBindings in the metabase, not just www.domain.com. This is causing the problem, espcially for shared hosting.

    I'd like to offer my customers a simple workaround via web.config if possible. Not everyone has the skills or desire to modify their WCF service just to work around this "feature". They'll just go to another web host that doesn't allow multiple host headers. Not good for business.

    Can you offer a workaround, or point me to a KB article that I can give my customers who want to use WCF?

    Thanks,
    Mark
  • viernes, 08 de junio de 2007 23:23David Brenchley Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I also have this problem with multiple headers to a website and consider it an important feature to have this ability.
  • sábado, 09 de junio de 2007 0:05Brian McNamara - MSFT Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    You might be able to work around this with a custom ServiceHostFactory, whose CreateServiceHost method looks through the Uri[] that IIS passes it, and filters out the extras so that only one Uri (the host header appropriate to the WCF service) is used.  A trivial subclass that just overrides this one method and filters the Uri[] parameter and then calls into the base class might be sufficient.

    http://msdn2.microsoft.com/en-us/library/system.servicemodel.activation.servicehostfactory.createservicehost.aspx

     

    http://msdn2.microsoft.com/en-us/library/aa702697.aspx

  • viernes, 09 de noviembre de 2007 18:05GraemeH Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    I tried this custom ServiceHostFactory suggestion,  but then I get the error (my binding requires https):

     

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

     

    If I try setting to the https Uri, I get an error because the MexdataExchange needs http.  How do I work round this?

     

    Thanks in advance

  • lunes, 12 de noviembre de 2007 14:35GraemeH Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    Maybe if I re-phrase this, someone might know of a solution:

     

    How can I use ServiceHostFactory in an IIS-hosted app to work with my https binding and the MexdataExchange http binding?

    It seems I can only either select the http base address or the https base address but not both.

     

    Thanks

  • jueves, 17 de abril de 2008 0:07Shan McArthurMVPMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    This is a significant issue because in the real world, most websites have multiple host headers (for multiple domain prefixes .com .net .org as well as for www and nonwww domain names). 

     

    Anyways, I just came accross the solution for .net 3.5:  http://blogs.msdn.com/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx

     

    Shan

  • martes, 27 de mayo de 2008 3:43Shan McArthurMVPMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    This is an INCREDIBLY important scenario.  The inability for WCF to host web services on a website with multiple host headers is a major defect.  The bottom line is that as soon as a second host header is added to the website, it breaks all of the services running on the website. Please revisit WCF design.

     

    Sincerely,

    Shan McArthur

  • lunes, 09 de junio de 2008 19:39JBBerke Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    this is important for me. Seems like without a host header the WSDL is generated using the local machine name. So I need two host headers one for each of the urls that access our site.

     

  • miércoles, 16 de julio de 2008 20:58Alan.M Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    Wenlong Dong,

     

    Please revisit this issue again.  This is a blocking issue for anyone that has existing applications, and they want to use System.ServiceModel.Activation.WebServiceHostFactory to build REST style web services that can respond over multiple hostnames in IIS.

  • martes, 09 de septiembre de 2008 11:30DanMeineck Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
  • martes, 23 de septiembre de 2008 20:41Serializer Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    This is an extremely important issue for me.

    My application switches configurations depending on the hostname it's being accessed on.

    So, one domain will use one database, whilst another domain could switch to an entirely different database (purely as an example). I'd like my services to also follow this pattern.

    With this model, I only want to install the app once, and simply point multiple host names at it in IIS. I don't want to have to upgrade 20 different webs every time I deploy an update. I don't want to have to maintain 20 different web.configs each with their own baseAddressPrefixFilters, just because each site has both a www.mydomain.com and a mydomain.com. This design decision seems extremely restrictive and causes obvious problems in very common hosting scenarios. In my opinion it would be well worth revisiting!

    Pete
  • jueves, 13 de noviembre de 2008 16:36xiondavis Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Another enthusiastic vote for multiple hostnames per scheme (http) support.

    For the use case that the service must listen on multiple host names (a typical scenerio in enterprise deployment.), the workaround that specifies multiple hostnames as absolute URIs in the config file has a serious flaw - httpGet cannot be enabled.

    The httpGetEnabled functionality in the serviceMetadata service behavior only supports relative paths that are in the IIS collection.  Basically, if this workaround is used, an absolute path must also be specified in the httpGetUrl attribute.  This service behavior does not support multiple absolute paths - it is not possible to enable httpGet for the service if the workaround is used.
  • jueves, 08 de enero de 2009 18:37kmd888 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    This may be a solution for those whose web servers have multiple host headers defined and each web servers may have a different set of host headers.

     

     

    Since WCF services hosted in IIS can have only one Base Address so we can create a custom service factory to intercept and create a System.ServiceModel.ServiceHost for a specific type of service with a dynamic URI or base address that is from the request URL.

     

     

    To do this:

     

    1) In your .svc file:

     

       Add the Factory attribute as the following:

     

       <%@ ServiceHost Language="C#"  Service="YourNameSpace.RssService" CodeBehind="~/App_Code/Service.cs" Factory="YourNameSpace.DynamicMultipleHostHeadersBinding" %>

     

     

    2) In your Service.cs file:

     

       Add the following class to your service.cs file:


    namespace YourNameSpace

       public class DynamicMultipleHostHeadersBinding : ServiceHostFactory

        {

     

            protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)

            {

                Uri[] dynamicAddress = new Uri[1];

                dynamicAddress[0] = GetDynamicURI();

                return base.CreateServiceHost(serviceType, dynamicAddress);

            }

     

            Uri GetDynamicURI()

            {

                String hostName = String.Format("{0}{1}/YourWebApplication/Service.svc", ((String.Compare(HttpContext.Current.Request.ServerVariables["HTTPS"], "on", true) == 0) ? "https://" : "http://"), HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString());

     

                return new Uri(hostName);

            }

        }


    ....

    ....


    3) Complile and run.

     

     

    Hope this helps,

     

    Kevin Duong

  • martes, 20 de enero de 2009 16:30Roy Higgs Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    +1 for this being important and needing to be fixed. ASAP. This is a huge barrier for WCF.
  • martes, 20 de enero de 2009 16:42Roy Higgs Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    kmd888 said:

    This may be a solution for those whose web servers have multiple host headers defined and each web servers may have a different set of host headers.

     

     

    Since WCF services hosted in IIS can have only one Base Address so we can create a custom service factory to intercept and create a System.ServiceModel.ServiceHost for a specific type of service with a dynamic URI or base address that is from the request URL.

     

     

    To do this:

     

    1) In your .svc file:

     

       Add the Factory attribute as the following:

     

       <%@ ServiceHost Language="C#"  Service="YourNameSpace.RssService" CodeBehind="~/App_Code/Service.cs" Factory="YourNameSpace.DynamicMultipleHostHeadersBinding" %>

     

     

    2) In your Service.cs file:

     

       Add the following class to your service.cs file:


    namespace YourNameSpace

       public class DynamicMultipleHostHeadersBinding : ServiceHostFactory

        {

     

            protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)

            {

                Uri[] dynamicAddress = new Uri[1];

                dynamicAddress[0] = GetDynamicURI();

                return base.CreateServiceHost(serviceType, dynamicAddress);

            }

     

            Uri GetDynamicURI()

            {

                String hostName = String.Format("{0}{1}/YourWebApplication/Service.svc", ((String.Compare(HttpContext.Current.Request.ServerVariables["HTTPS"], "on", true) == 0) ? "https://" : "http://"), HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString());

     

                return new Uri(hostName);

            }

        }


    ....

    ....


    3) Complile and run.

     

     

    Hope this helps,

     

    Kevin Duong



    Kevin, I don't believe this solution will work. The problem is that you will get into a first one in wins scenario. So if somebody first hits the service through http then http now becomes your base address so if someone subsequently hits the site through https it won't work. And vice versa. This is the crux of the issue. You can't dynamically build your service endpoint because the first one in wins. This is really a huge issue with WCF and, IMO, should be fixed through a service pack ASAP.
  • jueves, 22 de enero de 2009 2:17Slackbits Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I just want to add one more post about this being a real issue for hosting.  One of the bigger reasons for allowing multiple base addresses for multiple host headers is AJAX.  Some of us would like to make RESTful services for AJAX calls in our web sites.  Notice the term web site and not web application.  Sure we could put all of the services on another virtual host called services.foobar.com, but when someone tries to make an XMLHTTPRequest from a page on www.foobar.com, espanol.foobar.com, or pick any other host header that handles that content, they will get an access denied error.  So then you will have to mess with setting the domain for the document, which can bring up more issues, specifically, that you might not have full control over all hosts in the foobar.com domain.

    So not allowing WCF services to have multiple base addresses for a service means that you cannot actually use WCF to make RESTful services like these.  (Which I though was a big reason for the JSON serialization in .Net 3.5)  So hopefully someone at MS is reading this and this can be bumped up in priority to maybe make it into a service pack.  It is not like MS is worried about adding in large features or changing the behavior of old ones to sell more.  (Referring to the action attribute of a form that is runat=server to actually be used... that was a fun issue)
  • viernes, 23 de enero de 2009 22:45cblaze22 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I cant belive microsoft made this by design.  I mean every website has two hosts, mywebsite.com and www.mywebsite.com.  So obvious.
    Mike Flynn
  • sábado, 24 de enero de 2009 20:19xiondavis Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    I agree with all of this - we used WCF as a client server communication mechanism for an off the shelf application (driven by an architect that wants to use the "new hip tech").  In my opinon, WCF is best suited for the quick and dirty internal IT bespoke app.  Not for software developers.

    I'm seeing more and more of this from Microsoft - things like LINQ and WCF are really "cool" and the Microsoft guys can demo "I put together a whole app framework in 15 min" but jeez - it doesn't scale, it is a b^&U to configure (and keep configured in a user-run-time environment) and we spend more and more time on things breaking due to network configuration, etc.  Oversigts such as multiple http headers don't help. 

    If i'm writing glorified Hello World, WCF is cool - but in the real world, its a bust.  Little things like the size limit on Proxy generation using SVCHOST show me that microsoft didn't intend to use it in a scaled enterprise environment. 

    End rant  :)

  • viernes, 20 de febrero de 2009 10:23graffic Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I agree too.

    Year 2009, developing with the "latest" Microsoft products and.... they do not support the most BASIC things. I mean, virtual hosting has been there years and years.

    I'm starting to believe that Microsoft has something against web applications. They plague all their products with small problems/bugs that make development more difficult and problematic.
  • jueves, 11 de junio de 2009 2:02James Peckham Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    hey all, i just had this experience described.

    i was getting this error in event viewer:

     

    Exception: System.ServiceModel.ServiceActivationException: The service '/TestService/Service1.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme net.tcp. There can be at most one address per scheme in this collection.

    Parameter name: item. ---> System.ArgumentException: This collection already contains an address with scheme net.tcp. There can be at most one address per scheme in this collection.



    Make sure that you check the C:\windows\system32\inetsrv\config\applicationHost.config file and ensures that there is only one http binding inside the <bindings> element.

    I had this problem with net.tcp when i ran appcmd set twice on TCP.

    see i had this:
                  <bindings>
                        <binding protocol="http" bindingInformation="*:80:" />
                        <binding protocol="net.tcp" bindingInformation="808:*" />
                        <binding protocol="net.pipe" bindingInformation="*" />
                        <binding protocol="net.msmq" bindingInformation="localhost" />
                        <binding protocol="msmq.formatname" bindingInformation="localhost" />
                        <binding protocol="net.tcp" bindingInformation="4545:*" />
                    </bindings>

    and i had to manually delete the extra net.tcp to get it to work again.
    James Peckham CSM Developer and Agilist http://www.jamespeckham.com
  • domingo, 19 de julio de 2009 4:18David N_2 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I have the same problem too.  I have a web-server with multiple headers + existing webservice.  I cannot add my new WCF service to the same website.  It has the same error "The exception message is: This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection."

    This is absolutely a huge problem, for small + middle size businesses.

    DQ 
    David N.
  • jueves, 23 de julio de 2009 8:39Kirkaiya Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    This is a significant issue because in the real world, most websites have multiple host headers (for multiple domain prefixes .com .net .org as well as for www and nonwww domain names). 

     

    Anyways, I just came accross the solution for .net 3.5:  http://blogs.msdn.com/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx

     

    Shan


    I know it's a year later, but the above solution (on Ram Poornalingam's blog) solved this issue for me, when I had two web-applications hosted on a shared-hosting provider, where the default website had one WCF service defined (using http) and the site in a subdomain (created as a seperate website in IIS, but at wcf.mydomain.com instead of www.mydomain.com) had a separate WCF service (also using http) defined.

    So if any other web-developers run into this issue, using the <baseAddressPrefixFilters> element (and simply adding the subdomain, without any port number, as a prefix) worked. Thanks Shan!

    Technology Applied
  • miércoles, 16 de septiembre de 2009 4:09VilundaUffe Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Couldn't agree more. This is really a severe issue!
  • jueves, 08 de octubre de 2009 13:19mamadero2 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    I found a nice alternative here:
    http://www.webhost4life.com/HostingKB/KnowledgebaseArticle50088.aspx

    <servicehostingenvironment>
    <baseaddressprefixfilters>
    <add prefix="http://www.example.com">
    </add>
    </baseaddressprefixfilters>

    </servicehostingenvironment></system.servicemodel>

  • lunes, 16 de noviembre de 2009 20:53MarkH2734 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Thanks for this post, it solved our problem. After reading so many similar solutions and none working this was a great and simple fix. In our case it was the addition of a secure URL that resulted in the second binding entry, the first should have been removed when the default https binding was removed but it was not.