DOGNET

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

异常图: /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/

 

错误:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。(This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.)

原因:此 WCF 宿主是 IIS ,并且此站点配置了多个主机头,如果 www.example.comwww.example-alias.com 。但 WCF 不支持对 IIS (Http Binding) 中的 WCF 多个主机头绑定。

解决:

方法1. 用绑定不同主机头的多个网站来部署这个 WCF。

方法2. 自定义 ServiceHostFactory

详细讨 论:

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

How can 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 scheme http"

I met this error, and wondered what this could be. The explanation is that "WCF services hosted in IIS can have only one Base Address", meaning that in IIS the website hosting the service can not be associated to http://www.example.com and http://example.com at the same time.

I don't know why this prevents a service to work, but I know this is annoying.
I found a couple of bloggers like Rob suggesting a solution with a coded custom ServiceHostFactory, which sounds terribly complicated to me as a workaround.

Fortunately there is a much simpler solution, just by touching the web.config file. Just add the following lines in the system.serviceModel section:
<serviceHostingEnvironment>

    <baseAddressPrefixFilters>

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

    </baseAddressPrefixFilters>

</serviceHostingEnvironment>

to only keep the service address.

 

 

经过实践,先在web.config里机加了这个设置后,出现新错误,然后再去掉这个设置,看下又不报错了,真是有意思,错误是莫名的出现又是莫名的消失,有哪位仁兄给解释下原因?

 

posted on 2010-09-10 17:41  DOGNET  阅读(2071)  评论(0编辑  收藏  举报