Handling Large Data with SharePoint 2010 Custom WCF Service

Calling your custom WCF web service successfully with a small, known and fixed amount of test data only to have it fail with large and variable real world data? You can follow these steps to try and track down the issue. However, if you continue to get a 400 Bad Request error, you might be exceeding the maximum message size quota. The solution is to increase this limit as follows:

[code language=”csharp”]SPWebService contentService = SPWebService.ContentService;
SPWcfServiceSettings wcfServiceSettings = new SPWcfServiceSettings();
wcfServiceSettings.ReaderQuotasMaxStringContentLength = Int32.MaxValue;
wcfServiceSettings.ReaderQuotasMaxArrayLength = Int32.MaxValue;
wcfServiceSettings.ReaderQuotasMaxBytesPerRead = Int32.MaxValue;
wcfServiceSettings.MaxReceivedMessageSize = Int32.MaxValue;
wcfServiceSettings.MaxBufferSize = Int32.MaxValue;
wcfServiceSettings.ReaderQuotasMaxDepth = Int32.MaxValue;
wcfServiceSettings.ReaderQuotasMaxNameTableCharCount = Int32.MaxValue;
wcfServiceSettings.ReceiveTimeout = TimeSpan.MaxValue;

contentService.WcfServiceSettings[“your_custom_service.svc”] = wcfServiceSettings;
contentService.Update();[/code]

Related posts

The Future of SharePoint

Embracing the AI Era for Enhanced Collaboration and Creativity In our rapidly evolving digital landscape, harnessing the power of AI and smart technology to

Read More »
Ready to talk about building your

Modern Workplace?