The WCF Configuration Complexity
Windows Communication Foundation (WCF), introduced in .NET 3.0, consolidated Microsoft's communication stacks (Web Services, .NET Remoting, MSMQ). While highly powerful, WCF gained a reputation for being notoriously difficult to configure. A simple service required pages of XML configuration in app.config defining bindings, behaviors, and endpoints.
With the release of .NET 4.0 in April 2010, Microsoft has addressed this friction with default configuration defaults.
What's New in WCF 4.0?
WCF 4.0 focuses on making Service-Oriented Architecture (SOA) implementation faster and more maintainable.
1. Default Endpoints and Bindings
In .NET 4.0, if a service does not define any endpoints in the configuration file, WCF automatically creates default endpoints for each base address using standard bindings. For example, a service running over HTTP gets a default BasicHttpBinding endpoint.
2. Discovery Services
WCF 4.0 adds native support for WS-Discovery, allowing client applications to dynamically locate service endpoints at runtime without hardcoding URLs.
3. WCF Routing Service
A built-in message router that acts as an intermediary. It can perform:
- ◆Content-based routing: Inspecting SOAP headers to route messages to specific servers.
- ◆Protocol bridging: Transforming a request from SOAP/HTTP to binary/TCP.
- ◆Failover: Routing to a backup server if the primary is down.
SOA Best Practices for WCF 4.0
When designing enterprise services, developers should follow:
- ◆Keep Contracts Independent: Interfaces (ServiceContracts) and DataContracts should be defined in separate assemblies to avoid sharing implementation code with clients.
- ◆Prefer Simplification: Use default configurations for standard service topologies.
- ◆Secure by Default: For intranet services, use NetTcpBinding with transport security. For internet services, use WSHttpBinding with message security or transition to REST endpoints.