понедельник, марта 03, 2008

This collection already contains an address with scheme http.

При очередной выкладке одного из WCF сервисов возникла проблема с настройкой сервиса на продакшн-сервере, получаем постоянно исключение следующего вида (уточнение, сам сервис хостился в среде asp.net в web приложении на iis, доступном сразу по нескольким хостам, приложение по сути является порталом, хостящим разные сайты):



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


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item



решение:

Данная ситуация случается в том случае, когда wcf-сервис может быть достугнут сразу по нескольким адресам....т.е. в нашем случае важно было указать из всех доступных хостов по указанному ip-адресу, на котором хостился web - сервис, только один в разрезе различных доступных binding-протоколов, как показано ниже в примере:


ссылки по теме:
http://blogs.msdn.com/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx



How can WCF support multiple IIS Binding specified per site ?


Background

IIS has web sites, which are containers for virtual applications which contain virtual directories. The application in a site can be accessed through one or more IIS binding.

IIS bindings provide two pieces of information – binding protocol and binding information. Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site.

Example

Binding protocol – HTTP

Binding Information – IPAddress , Port, Hostheader

IIS supports specifying multiple IIS bindings per site, which results in multiple base addresses per scheme. A WCF service hosted under a site allows binding to only one baseAddress per scheme.



Solution in .Net Fx 3.0:Supporting Multiple IIS Bindings Per Site

Solution in .Net Fx3.5: BaseAddressPrefixFilters





Specifying a prefix filter at the appdomain level via config allows for filtering out unnecessary schemes. The incoming base addresses, supplied by IIS, are filtered based on the optional prefix list filter. By default, when prefix is not specified all addresses are passed through. Specifying the prefix will result in only the matching base address for that scheme to be passed through.


Example


   <system.serviceModel>

<serviceHostingEnvironment>

<baseAddressPrefixFilters>

<add prefix=”net.tcp://payroll.myorg.com:8000”/>

<add prefix=”http://shipping.myorg.com:9000”/>

</baseAddressPrefixFilters>

</serviceHostingEnvironment>

</system.serviceModel>





In the above example, net.tcp://payroll.myorg.com:8000 and http://shipping.myorg.com:9000 are the only base addresses, for their respective schemes, which will be allowed to be passed through. The baseAddressPrefixFilter does not support any wildcards .

The baseAddresses supplied by IIS may have addresses bound to other schemes not present in baseAddressPrefixFilter list. These addresses will not be filtered out.



ссылки по теме:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=373333&SiteID=1
http://www.robzelt.com/blog/2007/01/24/WCF+This+Collection+Already+Contains+An+Address+With+Scheme+Http.aspx
http://www.bokebb.com/dev/english/2047/posts/204720109.shtml

Комментариев нет: