Home > Programming > WCF Data Services and maxReceivedMessageSize

WCF Data Services and maxReceivedMessageSize

We have a WCF Data Service (Astoria) that uses most of the default configuration settings. Every once in a while, a client would receive the following exception:

System.Data.Services.Client.DataServiceRequestException: An error occurred while processing this request. ---> System.Data.Services.Client.DataServiceClientException: BadRequest

This exception only occurs when the client sends a large message. The default message size in WCF is 65536. Since we’re using a WCF Data Service and not a normal WCF Service, adding a WCF Data Service (.svc) to the project does not auto-generate the service/binding information in the config. To increase the message size, I needed to manually enter the service/binding information:

<system.serviceModel>
  <services>
    <service name="MyNamespace.MyService">
      <endpoint bindingConfiguration="msgSize" address="" binding="webHttpBinding" contract="System.Data.Services.IRequestHandler" />
    </service>
  </services>
  <bindings>
    <webHttpBinding>
      <!-- 2097152 = 2 MB-->
      <binding name="msgSize" maxReceivedMessageSize="2097152" maxBufferSize="2097152" />
    </webHttpBinding>
  </bindings>
</system.serviceModel>

The service name is the class (.svc) that inherits from System.Data.Services.DataService<T>.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: