Creating a multiple-endpoint service
For traditional distributed communication services, we will open the service over a certain transport-specific endpoint such as HTTP endpoint. If we need to expose it via another different transport layer, we will probably have to add additional code to implement the new endpoint. The WCF programming model separates the service implementation and underlying transport layer so that we can conveniently expose a single service implementation via multiple heterogeneous endpoints (with different a transport layer and binding configuration).
How to do it...
First, we make sure our
ServiceContract
is ready for various endpoint bindings we want to use to expose it. Some bindings may have special requirements onServiceContract
(such as MSMQ-based bindings). The following sample contract is ready for most built-in bindings:[ServiceContract] public interface ICounterService { [OperationContract] void Increment(); [OperationContract...