sharepoint 2010 WCF : The MaxStringContentLength string content length quota (8192)

本文介绍如何解决 SharePoint 2010 中 WCF 服务处理大型消息时出现的最大字符串长度限制问题。通过设置 Web 应用级别的特性接收器来调整 XML 读取配额及消息大小限制。

The ERROR: sharepoint 2010 WCF : The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader

 

Steps to set custom settings for large message support...        

Some items to add based on my trials to get this to work with large messages:


First, to update the configuration for a custom WCF service -add a WebApplication level feature with nothing more then a feature receiver. The receiver should override "FeatureInstalled" as follows:

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;
        contentService.WcfServiceSettings["mycustomservice.svc"] = wcfServiceSettings;
        
        contentService.Update(true);
}

Obviously, the values listed above are the extreme cases and should be set according to what your service will need. Also, the key for the indexer used for the WcfServiceSettings collection is the name of your service file. If you place the file in a subdirectory -do not include the subdirectory name as part of the key. 


Thus, if your service is deployed to the ISAPI directory under: 
/MyCompany/MyCustomService.svc 

the key for the WcfServiceSettings collection would be:

mycustomservice.svc


CAUTION: The key, as stated above, is case sensitive. The key should be all lowercase.

 

More to Link :

MSDN : http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebservice.wcfservicesettings(v=office.14).aspx

Blog :  http://blogs.planetsoftware.com.au/paul/archive/2011/06/28/custom-wcf-services-in-sharepoint-2010ndashpart-1.aspx and

http://www.elumenotion.com/Blog/Lists/Posts/Post.aspx?List=64b38372-f170-48e3-9720-d3398b3f211c&ID=121&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:%20ElumenotionBlogPosts%20%28Elumenotion%20Blog%20-%20WSS%20and%20MOSS%29

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值