Thursday, January 31, 2013

Richer WCF 4.5

.net 4.5 has come up with lot of new rich features which makes developer’s life more easier & richer. WCF 4.5 has several new features which simplifies the development & as well some added new features which makes development more richer. The main objective of WCF 4.5 is to simplify the development & enhance the WCF communication with modern standards.Will discuss the new features in summery in this post & will discuss the features in detail in the next posts.

1. Task based Async Support

By default, Add Service Reference generates Task-returning async service operation methods. This is done for both synchronous and asynchronous methods. This allows you to call the service operations asynchronously using the new Task based async programming model. When you call the generated proxy method, WCF constructs a Task object to represent the asynchronous operation and returns that Task to you. The Task completes when the operation completes.  When implementing an async operation you can implement it as a task-based async operation.

2. WCF Simplification Features

So many new features have been added to WCF 4.5 to simplify the development & maintenance.
  • Simplified Generated Configuration Files
  • WCF Configuration file will be validated as a part of the Visual Studio build process so that developer can see the errors & warning before running or deploying the service.
  • XML editor tool tips are available for every configuration element in the service configuration section to provide details about the elements

3. WebSocket Support

WebSockets is a technology that provides true bidirectional communication over ports 80 and 443 with performance characteristics similar to TCP.NetHttpBinding & NetHttpsBinding are two new bindings have been added to support communication over a WebSocket transport. 

4. Configuring WCF Services in Code

Having WCF configurations inside the configuration files makes the service maintainability high as no re-compilation in required on any configuration changed. But it is difficult as there is no way of debugging the elements in the configuration files. In WCF 4.0 configuring service in code was easier in the Self hosted scenario but not in the Service Host. With .NET 4.5, WCF provides an easier way to configure both self-hosted and web hosted services in code. For more information

5. ChannelFactory Caching

At the WCF client applications we use ChannelFactory classes to create the communication channel with a WCF application. But when a instance of ChannelFactory is created some overhead because it involves some operations. To help minimize this overhead, WCF can cache channel factories when you are using a WCF client proxy.

6. Compression and the Binary Encoder

With WCF 4.5 binary encodes supports the compression over the HTTP, HTTPS, and TCP protocols. The type of compression is configured with the CompressionFormat property. Both the client and the service must configure the CompressionFormat property.

7. UDP Support

WCF 4.5 now supports UDP transport.