What's new in WCF 4.5 - Part 4
WCF 4.5 support for true asynchronous streaming. Let see what is mean by true asynchronous streaming
- In previous version, When WCF service is sending streamed messages to multiple clients. Service will be block its thread to transfer to next client till the slow client is received the message.
- But in case of WCF4.5, service does not block one thread per client anymore and will free up the thread to service another client
How to enable asynchronous streaming?
- In previous versions of WCF when receiving a message for an IIS-hosted service that used streaming message transfer, ASP.NET would buffer the entire message before sending it to WCF. This would cause large memory consumption.
- This buffering has been removed in .NET 4.5 and now IIS-hosted WCF services can start processing the incoming stream before the entire message has been received, thereby enabling true streaming.
Generating a Single WSDL Document
In WCF 4.0 and lower version, generated wsdl file does not contain all metadata information in single file. WSDL file will refer the other document using ‘import’ statement as shown below. So when third party try to consume the service using WSDL has to explicitly add these references.
In WCF 4.5, service provide two option to create the wsdl, we can create wsdl information in single file
WebSocket is a web technology providing dbi directional communications channels over a single TCP connection.
WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application. The WebSocket Protocol is an independent TCP-based protocol.
Two new bindings are added in WCF4.5 to support communication over WebSocket. NetHttpBinding NetHttpsBinding
- Always create the service with Interface->Implementation format, mention the contract in Interface.
- Define the service in Class library and refer the class library in Host project. Don’t use service class in host project.
- Change the instance mode to per call as default.
- Always catch exception using try/catch block and throw exception using FaultException < T >.
- Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.