In WCF any receiving message is delivered only once entire message has been received. What I mean here is that first message is buffered at the receiving side and once it is fully received it gets delivered to the receiving end. Main problem with this approach is that receiver end is unresponsive while message is getting buffered. So default way of message handling in WCF is ok for small size messages but for the large size messages this approach is not good. So to overcome this problem Streaming in WCF come into action.
Steaming and Binding
- TCP, IPC and HTTP bindings support streaming.
- For all the Binding streaming is disabled by default.
- Streaming of the message should be enabled in the binding to override the buffering and enable the streaming.
- TransferMode property should be set according to the desired streaming mode in the bindings.
- Type of TransferMode property is enum TransferMode
Configuring Streaming in Config file
- <system.serviceModel>
- <services>
- <service name="OneWayService.Service1" behaviorConfiguration="OneWayService.Service1Behavior">
- <!-- Service Endpoints -->
- <endpoint address="" binding="basicHttpBinding" bindingConfiguration="StreamedHttp" contract="OneWayService.IService1">
- <identity>
- <dns value="localhost" /> </identity>
- </endpoint>
- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service>
- </services>
- <bindings>
- <basicHttpBinding>
- <binding name="StreamedHttp" transferMode="Streamed" /> </basicHttpBinding>
- </bindings>
- <behaviors>
- <serviceBehaviors>
- <behavior name="OneWayService.Service1Behavior">
- <serviceMetadatahttpGetEnabled="true" />
- <serviceDebugincludeExceptionDetailInFaults="false" /> </behavior>
- </serviceBehaviors>
- </behaviors>
- </system.serviceModel>