WCF services getting errors when hosting in IIS

Published Wednesday, June 4, 2008 11:42 AM

This post is more for my own records than anything and I have been meaning to write this down for some time.

Problem:

Had a WCF Web Service that was being hosted in IIS. Worked in dev and test fine. Moved to prod and bang, I get the following error:

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

 

Issue:

The production server had multiple host headers defined within IIS, meaning that the HTTP base address being passed through actually consisted of 2 base addresses with the HTTP scheme, which is not allowed when hosting WCF services in WCF.

The Solution:

Easy: Remove the multiple host headers. In my scenario, this was a viable solution as the multiple host headers were not actually necessary and represented some 'left over' configuration.

Harder, but more flexible and solid: Create a custom service factory to strip out the unwanted base address as outlined in a good post by Rob Zelt.

by Glav
Filed under: , , ,

Comments

# Glav said on Tuesday, July 29, 2008 10:08 PM

Nice solution ranamauro. Well done.

Leave a Comment

(required) 
(required) 
(optional)
(required) 

This Blog

Syndication