自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

WCF字符串過長問題解決方法指南

開發(fā) 開發(fā)工具
WCF字符串過長問題在實際使用中比較常見。不過這種問題的解決方法也是比較簡單的,在這里就為大家詳細介紹相關(guān)解決方案。

WCF框架是一個比較常用的開發(fā)框架,可以幫助開發(fā)人員實現(xiàn)許多功能,提供了相當大的幫助。編寫基于WCF服務(wù)的程序時,向WCF服務(wù)端發(fā)送一長串的HTML源碼,結(jié)果客戶端收到提示如下:#t#

格式化程序嘗試對消息反序列化時引發(fā)異常: 對操作“AddArticle”的請求消息正文進行反序列化時出現(xiàn)錯誤。讀取 XML 數(shù)據(jù)時,超出***字符串內(nèi)容長度配額 (8192)。通過更改在創(chuàng)建 XML 讀取器時所使用的 XmlDictionaryReaderQuotas 對象的 MaxStringContentLength 屬性,可增加此配額。 第 64 行,位置為 79。

WCF字符串過長問題主要是maxStringContentLength和maxReceivedMessageSize的設(shè)置會影響到消息的發(fā)送和接收,于是全部改為2MB大小,即2097152。

客戶端app.config修改以解決WCF字符串過長問題:

  1. < bindings> 
  2. < basicHttpBinding> 
  3. < binding name="BasicHttpBinding_ShareService" 
    closeTimeout="00:01:00" 
  4. openTimeout="00:01:00" receiveTimeout="
    00:10:00"
     sendTimeout="00:01:00" 
  5. allowCookies="false" bypassProxyOnLocal=
    "false" hostNameComparisonMode="StrongWildcard" 
  6. maxBufferSize="65536" maxBufferPoolSize=
    "524288" maxReceivedMessageSize="2097152" 
  7. messageEncoding="Text" textEncoding=
    "utf-8" transferMode="Buffered" 
  8. useDefaultWebProxy="true"> 
  9. < !-- Reset maxStringContentLength 
    for deserialize --
    > 
  10. < readerQuotas maxDepth="32" 
    maxStringContentLength="2097152"
     maxArrayLength="16384" 
  11. maxBytesPerRead="4096" maxName
    TableCharCount
    ="16384" /> 
  12. < security mode="None"> 
  13. < transport clientCredentialType="None" 
    proxyCredentialType="None" 
  14. realm="" /> 
  15. < message clientCredentialType="UserName" 
    algorithmSuite="Default" /> 
  16. < /security> 
  17. < /binding> 
  18. < /basicHttpBinding> 
  19. < /bindings> 

服務(wù)端web.config修改解決WCF字符串過長問題:

 

  1. < system.serviceModel> 
  2. < !-- add for the message size --> 
  3. < bindings> 
  4. < basicHttpBinding> 
  5. < binding name="NewBinding2MB" 
    maxReceivedMessageSize="2097152"> 
  6. < readerQuotas maxString
    ContentLength
    ="2097152" /> 
  7. < /binding> 
  8. < /basicHttpBinding> 
  9. < /bindings> 
  10. < !-- add for the message size --> 
  11. < behaviors> 
  12. < serviceBehaviors> 
  13. < behavior name="Web.WCF.
    ShareServiceBehavior"
    > 
  14. < serviceMetadata httpGetEnabled="true"/> 
  15. < serviceDebug includeException
    DetailInFaults
    ="false"/> 
  16. < /behavior> 
  17. < /serviceBehaviors> 
  18. < /behaviors> 
  19. < serviceHostingEnvironment aspNet
    CompatibilityEnabled
    ="true"/> 
  20. < services> 
  21. < service behaviorConfiguration=
    "Web.WCF.ShareServiceBehavior" 
    name="Web.WCF.ShareService"> 
  22. < endpoint address="" binding=
    "basicHttpBinding" bindingConfiguration=
    "NewBinding2MB" contract="Web.WCF.ShareService"/> 
  23. < endpoint address="mex" binding=
    "mexHttpBinding" contract="IMetadataExchange"/> 
  24. < /service> 
  25. < /services> 
  26. < /system.serviceModel> 

 

責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2009-12-22 11:21:43

WCF跨域訪問

2009-12-28 10:56:45

WPF Image

2010-07-29 15:28:47

Flex安全沙箱

2009-07-17 14:33:05

Jython中文問題

2009-02-26 11:13:41

Weblogic中間件JSP

2010-05-26 11:08:33

SVN管理

2009-06-09 15:51:07

Java ee中文問題解決方法

2010-08-03 09:12:52

Flex安全沙箱

2009-02-18 14:28:23

編碼亂碼JSP

2010-01-13 21:06:37

雙絞線

2011-05-18 14:00:30

在線備份

2009-08-14 13:49:58

Rails中文問題

2009-11-17 10:43:59

ubuntu 9.10輸入法解決方法

2010-05-11 15:09:51

Unix系統(tǒng)

2009-10-29 10:04:57

VB.NET Read

2010-02-23 17:12:01

WCF字符串

2009-07-22 17:50:14

2010-12-31 16:31:08

服務(wù)器常見問題

2011-03-18 18:47:34

QtMySQL

2013-06-14 10:48:53

IIS 7
點贊
收藏

51CTO技術(shù)棧公眾號