locked
WCF Service giving error on returning with heavy data RRS feed

  • Question

  • I am completely new with the WCF services and facing an issue while using the WCF service in my silverlight client. I need to send a WCF request to server to fetch data which would be binded to chart in silverlight. Now one of the case returns a data of a list having around 42000 key value pairs. When the service returns the data to silverlight it throws an error:

    "The remote server returned an error: NotFound."

    I am suspecting this error because of the data issue because when the same request returns only 7000 points it gets completed properly. 

    I am using basichttpbinding with the following settings in ServiceReferences.Clientconfig

    <basicHttpBinding>
                    <binding name="BasicHttpBinding_ICommonService" maxBufferSize="2147483647" receiveTimeout="00:10:00"
                        maxReceivedMessageSize="2147483647" closeTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" >
                        <security mode="None" />
                    </binding>
    </basicHttpBinding>
    Can anyone look at this and suggest what is the best way to do this..
    Thanks a lot in advance..


    Thursday, September 9, 2010 10:06 AM

Answers

  • Hi Neon,

    I think your web.config should be like this >>>

     

    <configuration>
        <connectionStrings>
      <add name="XXXConnectionString" connectionString="Data Source=XXX;Initial Catalog=XXX;Persist Security Info=True;User ID=XXX;Password=XXX;Timeout=1000000000"
       providerName="System.Data.SqlClient" />
     </connectionStrings>
     
        <!--<system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpRuntime maxRequestLength="2147483647"  useFullyQualifiedRedirectUrl="true"
              executionTimeout="45" />
      </system.web>-->

        <system.webServer>
            <modules runAllManagedModulesForAllRequests="true"/>
        </system.webServer>
     
        <system.serviceModel>
            <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
            <client/>
            <bindings>
                <basicHttpBinding>
                    <binding name="LargeData" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
                        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="XXX.Web.XXXServiceBehavior">
                        <serviceMetadata httpGetEnabled="true"/>
                        <serviceDebug includeExceptionDetailInFaults="true"/>
                        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                        <bufferedReceive maxPendingMessagesPerChannel="2147483647"/>
                    </behavior>
                    <behavior name="">
                        <serviceMetadata httpGetEnabled="true"/>
                        <serviceDebug includeExceptionDetailInFaults="false"/>
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <services>
                <service behaviorConfiguration="XXX.Web.XXXServiceBehavior" name="XXX.Web.XXXService">
                    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="LargeData" contract="XXX.Web.IXXXService">
                        <identity>
                        
                        </identity>
                    </endpoint>
                </service>
            </services>
        </system.serviceModel>
     
        <system.web>
            <compilation debug="true"/>
      </system.web>
    </configuration>

     

    I hope that help you ...

    best Regards

    Ali Derbaj

    Friday, September 10, 2010 3:00 AM

All replies

  • It looks like you are already using the max maxReceivedMessageSize="2147483647". Can you just use fiddler to catch the exact error message it might be something else.

    Otherwise maybe think of breaking up the data in multiple calls 

    Thursday, September 9, 2010 10:33 AM
  • Hi Anton,

    Thanks for your quick reply. It seems that I figured out what was going wrong. On enabling the WCF tracing I found the following error message:

    There was an error while trying to serialize parameter http://tempuri.org/:GetLiveDataResult. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. '.  Please see InnerException for more details.

    On doing a bit of more reading on this, I found that we can increase MaxItemsInObjectGraph by adding the following elements in web and client config files:

    On server side:

    <behaviors>
          <serviceBehaviors>  
            <behavior name=

    <behaviors>

          <serviceBehaviors>  

            <behavior name="MyName">

    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>

            </behavior>


    and on client side:

    <system.serviceModel>

    <behaviors>

    <endpointBehaviors>

    <behavior name="LargeEndpointBehavior">

    <dataContractSerializer maxItemsInObjectGraph="100000"/>

    </behavior>

    </endpointBehaviors>

    </behaviors>

        </system.serviceModel>

    Friday, September 10, 2010 2:45 AM
  • Hi Neon,

    I think your web.config should be like this >>>

     

    <configuration>
        <connectionStrings>
      <add name="XXXConnectionString" connectionString="Data Source=XXX;Initial Catalog=XXX;Persist Security Info=True;User ID=XXX;Password=XXX;Timeout=1000000000"
       providerName="System.Data.SqlClient" />
     </connectionStrings>
     
        <!--<system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpRuntime maxRequestLength="2147483647"  useFullyQualifiedRedirectUrl="true"
              executionTimeout="45" />
      </system.web>-->

        <system.webServer>
            <modules runAllManagedModulesForAllRequests="true"/>
        </system.webServer>
     
        <system.serviceModel>
            <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
            <client/>
            <bindings>
                <basicHttpBinding>
                    <binding name="LargeData" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
                        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="XXX.Web.XXXServiceBehavior">
                        <serviceMetadata httpGetEnabled="true"/>
                        <serviceDebug includeExceptionDetailInFaults="true"/>
                        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                        <bufferedReceive maxPendingMessagesPerChannel="2147483647"/>
                    </behavior>
                    <behavior name="">
                        <serviceMetadata httpGetEnabled="true"/>
                        <serviceDebug includeExceptionDetailInFaults="false"/>
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <services>
                <service behaviorConfiguration="XXX.Web.XXXServiceBehavior" name="XXX.Web.XXXService">
                    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="LargeData" contract="XXX.Web.IXXXService">
                        <identity>
                        
                        </identity>
                    </endpoint>
                </service>
            </services>
        </system.serviceModel>
     
        <system.web>
            <compilation debug="true"/>
      </system.web>
    </configuration>

     

    I hope that help you ...

    best Regards

    Ali Derbaj

    Friday, September 10, 2010 3:00 AM