none
WCF MaxArrayLength

    Question

  • I have an SL4 app consuming a WCF service which returns an array of short.  It works great until the array exceeds 65,536 elements.  I tried increasing the MaxArrayLength in the Web.config but it had no affect.  I could not find anywhere on the client side to adjust the MaxArrayLength.  Paging is not an option so I need to figure out which parameter needs to be adjusted.

    Web.Config:

    <service name="MyApp.MyService">
    <endpoint address="" binding="customBinding" bindingConfiguration="MyApp.MyService.customBinding0" contract="MyApp.MyService"/>
    	<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
    
    <customBinding>
    	<binding name="MyApp.MyService.customBinding0">
    		<binaryMessageEncoding>
    			<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
    		</binaryMessageEncoding>
    		<httpTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
    </binding>
    </customBinding>


     

    ServiceReferences.ClientConfig:

    <customBinding>
    <binding name="CustomBinding_MyService">
    <binaryMessageEncoding/>
    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
    </binding>
    </customBinding>


     

    Sunday, February 13, 2011 7:08 PM

Answers

  • I finally figured it out.  My original settings were OK.    I just had to increase the maxItemsInObjectGraph property.

    I added the following behaviour

    <behavior name="Behaviors.EndpointBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>

    and added the following parameter to my endpoint:

    behaviorConfiguration="Behaviors.EndpointBehavior"

    Wednesday, February 16, 2011 8:32 PM

All replies

  •         <binding name="PictureBindingConfig" closeTimeout="00:05:00" openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:30:00" transferMode="Buffered" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="None">
                <!--<transport protectionLevel="EncryptAndSign" />-->
              </security>
            </binding>

    Use the below configuration at server side

            <binding name="httpBindingConfig" closeTimeout="00:05:00" openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:30:00" transferMode="Buffered" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">

              <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />

              <security mode="None">

              </security>

            </binding>


    use the above binding config in your endpoint as shown below

     <endpoint name="TestService" address="" bindingConfiguration="httpBindingConfig" binding="basicHttpBinding" contract="TestService.ITestService" />

    If you create proxy using SLSvcutil then it will create the respective client side configuration as well.

    Tuesday, February 15, 2011 12:13 AM
  • Thanks, but those settings did not work.  Since it is cutting off at 65,536 isn't there just a parameter somewhere that is defaulting to 65,536 that needs to be increased?

    Tuesday, February 15, 2011 5:38 PM
  • the cutoff limit 65,536 is default and that value we can change it using the configuration I mentioned. Could you pls post your modified service host web.config here. As well as the client web.config.


    Wednesday, February 16, 2011 4:58 AM
  • Modified web.config

    		<bindings>
          <basicHttpBinding>
            <binding name="WebDB.ImageService.customBinding0" closeTimeout="00:05:00" openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:30:00" transferMode="Buffered" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="None">
              </security>
            </binding>
          </basicHttpBinding>
     			<!--<customBinding>
    				<binding name="WebDB.ImageService.customBinding0">
    					<binaryMessageEncoding>
    						<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
    					</binaryMessageEncoding>
    					<httpTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
    				</binding>
    			</customBinding>-->
    		</bindings>
    
    				<!--<endpoint address="" binding="customBinding" bindingConfiguration="WebDB.ImageService.customBinding0" contract="WebDB.ImageService"/>-->
            <endpoint name="TestService" address="" bindingConfiguration="WebDB.ImageService.customBinding0" binding="basicHttpBinding" contract="WebDB.ImageService" />
    				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>


    Modified ServiceReferences.ClientConfig

    <bindings>
                <!--<customBinding>
                    <binding name="CustomBinding_ImageService">
                      <binaryMessageEncoding/>
                        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
                    </binding>
                </customBinding>-->
             
              <basicHttpBinding>
                <binding name="CustomBinding_ImageService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered"  
                         closeTimeout="00:05:00" openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:30:00">
                  <security mode="None"/>
                </binding>
              </basicHttpBinding>
              
            </bindings>
            <client>
              <endpoint address="http://localhost:1712/ImageService.svc" binding="basicHttpBinding"
                        bindingConfiguration="CustomBinding_ImageService" contract="ImageService.ImageService"
                        name="CustomBinding_ImageService" />
                <!--<endpoint address="http://localhost:1712/ImageService.svc" binding="customBinding"
                    bindingConfiguration="CustomBinding_ImageService" contract="ImageService.ImageService"
                    name="CustomBinding_ImageService" />-->
            </client>


    Wednesday, February 16, 2011 6:32 PM
  • I finally figured it out.  My original settings were OK.    I just had to increase the maxItemsInObjectGraph property.

    I added the following behaviour

    <behavior name="Behaviors.EndpointBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>

    and added the following parameter to my endpoint:

    behaviorConfiguration="Behaviors.EndpointBehavior"

    Wednesday, February 16, 2011 8:32 PM