Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have setup a WCf service in my project using this tutorial: http://msdn.microsoft.com/en-us/library/ff521581.aspx

However, I'm POSTing lots of byte[] data to the service tocreate a file. I basically have a canvas drawing, which I convert to byte[] using javascript and then POST it to the server to create a new file.

However, this approach is flawed. The server errors out if the the byte data is big. I followed the turorial and could not find a way to increase the limits. I did find ways to modify Web.Config file, but my WCF service does not has a web.config file.

Any help is greatly appreciated!

share|improve this question
    
This may be better suited for Stack Overflow –  RJ Cuthbertson Jul 23 '12 at 19:57
    
Since the tutorial for setting up a wcf service based on SharePoint SharePoint, I thought it was best to post here. I will play around a bit, and post my results here. Because the way MSDN has that tutorial, I'm pretty sure a lot of people will have problem setting up configurations for the wcf service. –  Pathachiever11 Jul 23 '12 at 20:14
    
I know what you're saying, and the rules of these forums are kind of convoluted. However, this is more specifically about WCF and IIS than about SharePoint. –  RJ Cuthbertson Jul 23 '12 at 20:24
    
You might find there is a web.config, you should check in the c:\inetpub\wwwroot\wss\virtualdirectories\<your web>\web.config –  Ian Jul 23 '12 at 20:50
add comment

3 Answers

You cannot use web.config to change the settings for the SharePoint WCF services because the Factory classes referenced in the *.svc file do the configuration 'automatically'.

But you can use the SPWcfServiceSettings class to modify the quotas. (Note: This changes the quotas for all WCF services in the Farm that use the factory classes).

Here is an example on how to use the class: http://www.elumenotion.com/Blog/Lists/Posts/Post.aspx?ID=121

share|improve this answer
    
I ended up implementing a Geneirc Handler, which did not impose any limits. Since I'm working on a client project, I really don't want my WCF service quotas to affect all WCF services on the farm. Thanks for pointing that out though! –  Pathachiever11 Jul 24 '12 at 22:12
    
Where should I use SPWcfServiceSettings? –  Codler Nov 14 '12 at 12:38
add comment

I solved this by creating a Feature and then add this code in FeatureInstalled method.

public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
    SPWebService contentService = SPWebService.ContentService;
    SPWcfServiceSettings wcfServiceSettings = new SPWcfServiceSettings();

    wcfServiceSettings.ReaderQuotasMaxStringContentLength = Int32.MaxValue;
    wcfServiceSettings.ReaderQuotasMaxArrayLength = Int32.MaxValue;
    wcfServiceSettings.ReaderQuotasMaxBytesPerRead = Int32.MaxValue;
    wcfServiceSettings.MaxReceivedMessageSize = Int32.MaxValue;

    // Note: "runtime.svc" must be in lowercase
    contentService.WcfServiceSettings["runtime.svc"] = wcfServiceSettings;

    contentService.Update(true);
}
share|improve this answer
add comment

I eneded up implementing a Generic Handler (.ashx), which did not impose any limits to the data I was POSTing.

If anyone is interested in ASHX handler in SharePoint, you can check out this article: http://www.lifeonplanetgroove.com/2010/10/15/adding-and-deploying-generic-handlers-ashx-to-a-sharepoint-2010-visual-studio-project/

I'm not sure why WCF didn't like my byte[], it was around 26KB.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.