WCF – Cannot have multiple base addresses

We recently had a need to support a distributed transaction across web service calls. The natural choice is WCF. We managed to get the transaction support working, but ran into another issue along the way.

WCF uses a stricter addressing scheme than ASMX. It only supports one “binding” per sheme. So, you can only have one valid HTTP:// address for your service.

This is not the case with IIS or ASMX services, where a web site can listen on multiple IPs via multiple DNS names. ASMX services automatically adjust by returning WSDL that is based on the address used when accessing the service. IIS also allows you to set up multiple host header names on a single site, but if you do this, WCF will throw back an error stating that it can only support 1 address per scheme.


I found the following article on MS Connect describing some workarounds, but none of them solve the root of the problem. In the end, you still have to pick one address per instance of the service.

There are some things that can help in certain scenarios, but your mileage may vary…

1- For WCF 3.0, you can override the ServiceHostFactory to select the desired base address. This is a pretty simple thing to do as described in Ram Poornalingam’s blog post.

2 – For WCF 3.5, you can use some new config settings to pick the appropriate base address. This is easier and is described in another post by Ram Poornalingam.

3 – The only real way to support multiple base addresses is to configure individual sites in IIS for the various base addresses that you need to support. To make things slightly simpler, each site can point to the same physical directory and can use the same app pool. This is noted as one of the workarounds on the MS Connect article.


For now, I’m going to see if we can make option 1 work. I created a common assembly that can be pulled into our services and used as the default factory. This will allow us to select the desired base address or just use the first one in the list.

One thought on “WCF – Cannot have multiple base addresses

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: