Handling Large Arrays in API V5 (.NET)
When transferring large amounts of data (large arrays) in Version 5 of the API when using .NET, some changes to the client configuration may be necessary. The following elements may need to be adjusted in app.config, for example :
· MaxReceivedMessageSize
· MaxBufferSize (should be same size as MaxReceivedMessageSize)
· MaxItemsInObjectGraph
For MaxItemsInObjectGraph, a custom behavior is needed, as shown in the following configuration file snippet:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICampaignManagementService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="6553600" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://adcenterapi.microsoft.com/Api/Advertiser/V5/CampaignManagement/CampaignManagementService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICampaignManagementService"
contract="ICampaignManagementService" name="BasicHttpBinding_ICampaignManagementService"
behaviorConfiguration="LargeQuotaBehavior"/>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
For further information, see the following article on MSDN.
Jeff Dillon, API Support