hunter.wang
hunter.wang

Reputation: 123

how to work around the default message size limit in WCF data service

I have encountered a problem with my WCF data service. One of tables contains too many data to return(about 80 fields) so that the size limit would be exceeded by only one record(above 60k by estimation, I can't tell accurately because the message can't be seen as a result of interruption of message outputting).

So far I have found that it can be worked around by two means.

For both solution are there some problems to overcome.

Upvotes: 4

Views: 5249

Answers (2)

Roy Dictus
Roy Dictus

Reputation: 33139

To use JSON with WCF Data Services, you need the WCF Data Services Toolkit, downloadable for free at http://wcfdstoolkit.codeplex.com.

This enables the option to tack on "$format=json" to the end of your REST queries, as in:

http://myservice/Products?$format=json

Upvotes: 1

Glenn Gailey - MSFT
Glenn Gailey - MSFT

Reputation: 91

For problem #1, check out the topic Streaming Provider (WCF Data Services), which includes this WCF configuration to enable large messages to and from an OData service using WCF Data Services:

 <system.serviceModel>
 <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
 <services>
     <!-- The name of the service -->
     <service name="PhotoService.PhotoData">
         <!--you can leave the address blank or specify your end point URI-->
         <endpoint binding="webHttpBinding" 
           bindingConfiguration="higherMessageSize" 
           contract="System.Data.Services.IRequestHandler"></endpoint>
     </service>
 </services>
 <bindings>
     <webHttpBinding>
         <!-- configure the maxReceivedMessageSize value to suit the max size of 
                  the request (in bytes) you want the service to receive-->
         <binding name="higherMessageSize" transferMode="Streamed"  
          maxReceivedMessageSize="2147483647"/>
     </webHttpBinding>
 </bindings>

For problem #2, the WCF Data Services client doesn't support JSON, only Atom XML. Have you tried the post Using System.Json for non-Silverlight projects? which seems to have some helpful info on other alternatives for parsing JSON from a data service on the client.

Upvotes: 1

Related Questions