Archive for April 15, 2014

Large Data and REST Services

When working with web services within SharePoint you sometimes need to be able to post and get large amounts of data through it. Instead of adding binding information to the web.config file(s), always a pain with SharePoint on deployment, depending on the context that the code is running under. It’s never a guarantee that you’ll have write permission to the necessary config files as you can never be certain the configured security will allow your write request.

A simpler method is to configure and add a SPWcfServiceSettings method for the web service that requires large amounts of data. The following few lines of code achieve this:

var spWcfServiceSettings = new SPWcfServiceSettings
    ReaderQuotasMaxStringContentLength = Int32.MaxValue,
    ReaderQuotasMaxArrayLength = Int32.MaxValue,
    ReaderQuotasMaxBytesPerRead = Int32.MaxValue,
    MaxReceivedMessageSize = Int32.MaxValue
SPWebService contentService = SPWebService.ContentService;
contentService.WcfServiceSettings["name_of_service_file.svc"] = spWcfServiceSettings;

Read more


Get every new post delivered to your Inbox

Join other followers: