Задайте вопросЗадайте вопрос
 

ОтвеченоThere can be at most one address per scheme in this collection.

  • 8 февраля 2007 г. 21:45Mark A. Richman Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

Ответы

  • 22 февраля 2007 г. 17:06Wenlong Dong Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Отвечено

    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 

Все ответы

  • 14 февраля 2007 г. 4:44Jeff Cao Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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.

  • 22 февраля 2007 г. 14:36Bing M_ Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

  • 22 февраля 2007 г. 17:06Wenlong Dong Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Отвечено

    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 

  • 23 февраля 2007 г. 16:27KevinBurton Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
     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

  • 28 февраля 2007 г. 3:15Mark A. Richman Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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
  • 8 июня 2007 г. 23:23David Brenchley Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    I also have this problem with multiple headers to a website and consider it an important feature to have this ability.
  • 9 июня 2007 г. 0:05Brian McNamara - MSFT Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

  • 9 ноября 2007 г. 18:05GraemeH Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

  • 12 ноября 2007 г. 14:35GraemeH Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

  • 17 апреля 2008 г. 0:07Shan McArthurMVPМедали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

  • 27 мая 2008 г. 3:43Shan McArthurMVPМедали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

  • 9 июня 2008 г. 19:39JBBerke Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.

     

  • 16 июля 2008 г. 20:58Alan.M Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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.

  • 9 сентября 2008 г. 11:30DanMeineck Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
  • 23 сентября 2008 г. 20:41Serializer Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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
  • 13 ноября 2008 г. 16:36xiondavis Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.
  • 8 января 2009 г. 18:37kmd888 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

  • 20 января 2009 г. 16:30Roy Higgs Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    +1 for this being important and needing to be fixed. ASAP. This is a huge barrier for WCF.
  • 20 января 2009 г. 16:42Roy Higgs Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.
  • 22 января 2009 г. 2:17Slackbits Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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)
  • 23 января 2009 г. 22:45cblaze22 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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
  • 24 января 2009 г. 20:19xiondavis Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

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

  • 20 февраля 2009 г. 10:23graffic Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.
  • 11 июня 2009 г. 2:02James Peckham Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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
  • 19 июля 2009 г. 4:18David N_2 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.
  • 23 июля 2009 г. 8:39Kirkaiya Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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
  • 16 сентября 2009 г. 4:09VilundaUffe Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Couldn't agree more. This is really a severe issue!
  • 8 октября 2009 г. 13:19mamadero2 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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>

  • 16 ноября 2009 г. 20:53MarkH2734 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.