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

WCF字符串如果過長該如何處理

開發(fā) 開發(fā)工具
在實(shí)際應(yīng)用中,我們經(jīng)常會(huì)遇到WCF字符串過程的一些問題。那么如何才能正確的解決這一問題呢。在這里將會(huì)做一個(gè)詳細(xì)介紹。

WCF服務(wù)中,如果我們遇到了程序中的字符串過長的話,應(yīng)該如何正確處理呢?在這里我們將會(huì)為大家詳細(xì)介紹一下WCF字符串的相關(guān)應(yīng)用技巧,以幫助大家解決在實(shí)際應(yīng)用中出現(xiàn)的一些特定問題。#t#

編寫基于WCF服務(wù)的程序時(shí),向WCF服務(wù)端發(fā)送一長串的HTML源碼,結(jié)果客戶端收到提示如下:

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

主要是maxStringContentLength和maxReceivedMessageSize的設(shè)置會(huì)影響到消息的發(fā)送和接收,于是全部改為2MB大小,即2097152。

客戶端app.config修改:

  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" maxNameTableCharCount="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修改:

 

  1. < system.serviceModel> 
  2. < !-- add for the message size --> 
  3. < bindings> 
  4. < basicHttpBinding> 
  5. < binding name="NewBinding2MB" maxReceivedMessageSize="2097152"> 
  6. < readerQuotas maxStringContentLength="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 includeExceptionDetailInFaults="false"/> 
  16. < /behavior> 
  17. < /serviceBehaviors> 
  18. < /behaviors> 
  19. < serviceHostingEnvironment aspNetCompatibilityEnabled="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> 

以上就是針對WCF字符串過程的解決方法。

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

2009-12-15 13:15:11

Ruby字符串

2009-12-21 18:39:24

WCF字符串過長問題

2010-11-26 09:51:54

MySQL字符串

2023-03-09 12:21:38

2022-04-12 07:32:40

引擎模式Spring策略模式

2010-07-14 16:35:52

Perl字符串處理函數(shù)

2010-08-04 11:23:15

Flex字符串

2025-03-31 08:04:50

MySQLCPU內(nèi)存

2012-07-03 11:18:20

運(yùn)維disable tab

2024-08-29 08:54:35

2023-02-02 08:56:25

線程池線程submit

2010-07-19 15:07:46

Perl字符串處理函數(shù)

2010-10-09 11:54:46

MySQL字符串

2018-01-24 19:59:03

數(shù)據(jù)庫Oracle壞塊

2019-05-09 15:31:23

攻擊服務(wù)器安全

2009-11-26 16:26:32

PHP字符串mbstr

2016-12-30 13:32:24

字符串算法代碼

2010-08-26 12:12:19

LMHOSTS文件

2010-11-26 11:20:31

MySQL字符串處理函

2019-08-12 14:25:09

編程算法PythonJavaScript
點(diǎn)贊
收藏

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