ditel 发表于 2015-8-17 09:55:15

wcf在IIS里面出现的一个异常(WCF 错误:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址)

  异常图: /Files/abc8103/WCF.pdf
  
  转贴网上的解决方案1:http://blogs.leoworks.net/feng/2009/09/13/There-can-be-at-most-one-address-per-scheme-in-this-collection/

  
  
                                                             WCF 错误:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。
               
                                                                                                                  WCF                                              2009年9月13日                         0                                                                                            错误:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。(Thiscollection already contains an address with scheme http.There can beat most one address per scheme in this collection.)
  原因:此 WCF 宿主是IIS ,并且此站点配置了多个主机头,如果 www.example.com与 www.example-alias.com 。但WCF 不支持对 IIS (Http Binding) 中的 WCF 多个主机头绑定。
  解决:
  方法1.用绑定不同主机头的多个网站来部署这个 WCF。
  方法2. 自定义 ServiceHostFactory
  详细讨 论:
  Therecan be at most one address per scheme in this collection.
  Howcan WCF support multiple IIS Binding specified per site ?
  WCF:Hosting multiple WCF services as one single service

  
  转贴网上的解决方案2:http://blog.befruit.com/2008/09/wcf-error-this-collection-already.html
      WCF error: "This collection already contains an address with schemehttp"      
                            I met this error, andwondered what this could be. The explanation is that "WCF serviceshosted in IIS can have only one Base Address", meaning that in IIS thewebsite hosting the service can not be associated to http://www.example.com and http://example.com at the sametime.
I don't know why this prevents a service to work, but Iknow this is annoying.
I found a couple of bloggers like Robsuggesting a solution with a coded custom ServiceHostFactory, which sounds terriblycomplicated to me as a workaround.
Fortunately there is a muchsimpler solution, just by touching the web.config file. Just add thefollowing lines in the system.serviceModelsection:
<serviceHostingEnvironment>
    <baseAddressPrefixFilters>
      <addprefix="http://www.example.com"/>
    </baseAddressPrefixFilters>
</serviceHostingEnvironment>
toonly keep the service address.
  
  
  经过实践,先在web.config里机加了这个设置后,出现新错误,然后再去掉这个设置,看下又不报错了,真是有意思,错误是莫名的出现又是莫名的消失,有哪位仁兄给解释下原因?

  
页: [1]
查看完整版本: wcf在IIS里面出现的一个异常(WCF 错误:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址)