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/

 

错误:此集合已经包含方案 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 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/abc8103/archive/2010/09/10/1823509.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值