WCF Exception: "There can be at most one address per scheme in this collection"

I'm beginning to see why people dislike WCF. 

I'm working on using WCF to feed an AJAX TreeView, and demos of it are FAST. However, in my debugging on my dev server I bumped into the exception:

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

The posters at http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/9e248455-1c4d-4c5c-851c-79d9c1631e21/#page:1 seem to be most vocal about the definiciencies of WCF in this respect - and they'd be right. What were Microsoft thinking? Most web applications need to respond to at least two domains to overcome the vagaries of user-inputted URLs, eg:

  • www.myapp.mysite.com
  • mapp.mysite.com
  • myapp

Are all potentially valid patterns for accessing an internal web application. We shouldn't need workarounds to get this to work.

Removing the extra host header record fixes the issue. Surely they weren't expecting people to write their WCF services under a separate, discrete URL, like wcf.myapp.mysite.com?

 

 

Published Mon, Mar 16 2009 11:39 AM by Nathan Pledger
Filed under:

Comments

# re: WCF Exception: "There can be at most one address per scheme in this collection"

Friday, March 20, 2009 4:06 AM by Grant Samuels

There is a simple fix for this in the WCF configuration, just add this before the closing system.servicemodel tag in your config file:

<serviceHostingEnvironment>

     <baseAddressPrefixFilters>

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

     </baseAddressPrefixFilters>

   </serviceHostingEnvironment>

# re: WCF Exception: "There can be at most one address per scheme in this collection"

Friday, March 20, 2009 8:26 AM by Nathan Pledger

Ah, excellent, thanks a lot.

Google didn't serve me too well that time, then!

# re: WCF Exception: "There can be at most one address per scheme in this collection"

Friday, May 15, 2009 11:04 AM by Lokkers

Grant's solution is excellent - that's just fixed an issue I've spent the last four hours trying to fix!

# re: WCF Exception: "There can be at most one address per scheme in this collection"

Thursday, April 08, 2010 9:00 PM by Ad

Many thanks - spot on. I had been trying to solve that for literally days!

# re: WCF Exception: "There can be at most one address per scheme in this collection"

Friday, September 03, 2010 7:55 PM by Alessandro

Thanks. Very good soluction.

# re: WCF Exception: "There can be at most one address per scheme in this collection"

Monday, June 06, 2011 4:07 PM by Lolo

Many Thanx @ Grant. Saved mi demo!

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 3 and 4 and type the answer here: