Sharing a physical address between multiple endpoints
WCF supports exposing a single service through multiple heterogeneous endpoints. Another great feature is letting multiple endpoints listen over the same physical transport address. For example, you want to host a WCF service that has multiple endpoints exposed. However, you only have a single HTTP URL open for listening. Then you can use this feature to make all those endpoints (as long as they’re using the same transport protocol) listen on the same URL.
How to do it...
Our sample service will expose two endpoints (one is IFoo and the other is IBar) and both of them will listen on the same HTTP URL:
The first thing we need to do is configure the service endpoints. We will still specify different values for the
address
attribute of the two endpoints. However, we will use a special attribute namedlistenUri
to supply the physical address (identical for both endpoints). The following screenshot shows the usage of both attributes:It is also...