Overview
By default, WCF limits the amount of data that can be transferred through an operation invokation in subtle ways. To override these default limits, you will need to alter both the client and service configuration. No changes to your code are needed, though.
Overview
The WCF system has internal limits on the size of various structures. These include service buffers and XML buffers. Both of these can be configured in an application's configuration files.
Service limits
A service provider or client can set limits using an endpoint binding configuration. The endpoint binding configuration has different options depending on the transport selected. Two main binding configuration element classes exist: ConnectionOrientedTransportBindingElement and HttpTransportBindingElement. The HttpTransportBindingElement class defines a MaxBufferSize property which is by default 64KB. The ConnectionOrientedTransportBidingElement class defines two buffer limits: MaxBufferSize (also set to 64KB by default) and ConnectionBufferSize which is used for chunking larger messages. By default, ConnectionBufferSize is 8KB.
The overall size limit of a transport's buffer pool is exposed by the MaxBufferPoolSize property of the TransportBindingElement class. By default, it is set to 512KB.
XML limits
If your service is expecting to send or receive large arrays (more than 16KB) then you will need to configure the MaxArrayLength XML reader quota. Depending on your data structures, you may also need to configure the MaxBytesPerRead and MaxDepth quotas. See the XmlDictionaryReaderQuotas class for more information.
Configuration
To set these configuration elements, you need to provide a binding configuration element in you configuration file. The following configuration file configures the endpoint's buffer to 128KB and allows for 64KB arrays. The example uses the netNamedPipeBinding to show some of the settings, but a similar approach should be followed for other transports.
<configuration>
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="ExampleBindingConfig" maxBufferSize="131072">
<readerQuotas maxArrayLength="65536" />
</binding>
</netNamedPipeBinding>
</bindings>
<services>
<service ...>
<endpoint binding="netNamedPipeBinding"
bindingConfiguration="ExampleBindingConfig"
... />
</service>
</services>
</system.serviceModel>
</configuration>
Versions
- Microsoft .NET Framework 3.5
Metadata
- Categories: Windows Communication Foundation, Software Development, .NET
- Additional keywords: transfer limits, WCF, buffers, large transfers
- Technorati Tags: .NET, WCF, Windows Communication Foundation, large messages, binary transfer, binding configuration