DLL
DLL

Reputation:

Silverlight & WCF: Max message size

When I pass a list of objects out of my silverlight app using WCF everything works fine until the List grows too big. It seems that when I exceed 80 items I get the error: The remote server returned an unexpected response: (404) Not Found

I'm presuming that it's because the List has grown too big as when the List had 70 items everyhing works fine. Strange error message though, right?

In the config file I change the maxBufferSize to the highest value that it will accept but still I can't have more then 80 items in my List.

How can I pass out large objects without having to split the object up?


Thanks Shawn, so where exactly do I do it? This is my ServiceReferences.ClientConfig

<configuration>
<system.serviceModel>
    <client>
      <!--"http://sy01911.fw.gsjbw.com/WcfService1/Service1.svc"-->
      <endpoint address="http://localhost/WcfService1/Service1.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService11"
            contract="SilverlightApplication1.ServiceReference1.IService1"
            name="BasicHttpBinding_IService1" />
    </client>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IService1" maxBufferSize="655360000"
                maxReceivedMessageSize="655360000">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_IService11" maxBufferSize="655360000"
                maxReceivedMessageSize="655360000">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
</system.serviceModel>


and this is the server config that you mentioned


<services>
  <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior" >
    <!-- Service Endpoints -->
    <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" >
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WcfService1.Service1Behavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Upvotes: 4

Views: 9382

Answers (3)

Xing
Xing

Reputation:

In server side, change the config file to make the service can accept large message.

  1. Add a basicHttpBinding configuration in <system.serviceModel> section:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
           <bindings>
             <basicHttpBinding>
                <binding name="MyBasicHttpBinding" maxReceivedMessageSize="300000000">
                   <security mode="None"/>
                   <readerQuotas maxStringContentLength="300000000"/>
                </binding>
             </basicHttpBinding>
           </bindings>
    .......
    
  2. Add the configuration to the service binding.

    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding" contract="WcfService1.IService1">
    

Upvotes: 2

Jacob Adams
Jacob Adams

Reputation: 4004

If you are sending out a large number of items from WCF, also make sure that maxItemsInObjectGraph is a relatively high number

<behaviors>
   <serviceBehaviors>
      <behavior name="YourBahvior">
         <dataContractSerializer maxItemsInObjectGraph="6553600"/>
      </behavior>
   </serviceBehaviors>
</behaviors>

Upvotes: 3

Shawn Wildermuth
Shawn Wildermuth

Reputation: 7468

There are two config files. The silverlight clientconfig will let you send the larger message, but if you'r eusing WCF, there is a server web.config that limits the size of the received message (to prevent DDOS attacks).

Upvotes: 2

Related Questions