title: Custom SharePoint 2010 WCF Service - How to set MaxReceivedMessageSize parameter
body: <p>I have developped a custom WCF Web Service within a SharePoint 2010 Visual Studio empty project.</p>
  
  <p>My web service is working well. The problem is related to the size of the request I can send to this web service. I have realized that is something around 300Kb. If I go bigger than that, the service/client is sending me an exception.</p>
  
  <p>I've looked around on the web and see that the MaxReceivedMessageSize setting may be my solution. I've tried using a FeatureActivated method to set this information using this kind of request:</p>
  
  <pre><code>// increase maximum size of requests to this web service: http://msdn.microsoft.com/en-us/library/ff599489.aspx
  SPWebService contentService = SPWebService.ContentService;
  contentService.ClientRequestServiceSettings.MaxReceivedMessageSize = -1;
  SPWcfServiceSettings csomWcfSettings = new SPWcfServiceSettings();
  csomWcfSettings.MaxReceivedMessageSize = 10485760; // 10MB
  contentService.WcfServiceSettings["PT-SP-P2S-DocumentCreator.svc"] = csomWcfSettings;
  contentService.Update(); // access denied thrown here!
  </code></pre>
  
  <p>With that code, I have an Access denied (I'm actually the Site Collection Administrator).</p>
  
  <p>I also know that this parameter may be set in the app.config of web service host but, in SharePoint, where to I need to change this parameter.</p>