日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

The maximum string content length quota (8192) has been exceeded while reading XML data

發布時間:2025/3/21 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The maximum string content length quota (8192) has been exceeded while reading XML data 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原文: The maximum string content length quota (8192) has been exceeded while reading XML data

?

問題場景:在我們WCF服務發布后,我們要確保服務端以及客戶端的配置文件允許合適大小的傳輸設置。筆者在發布WCF服務時,服務端的綁定未做傳輸大小的設置(采用了默認,maxStringContentLength默認大小為8192),而我們在傳輸序列化的數據時,大小超過了這個限制。

?讀取 XML 數據時,超出最大字符串內容長度配額 (8192)。通過更改在創建 XML 讀取器時所使用的 XmlDictionaryReaderQuotas 對象的 MaxStringContentLength 屬性,可增加此配額。

?

問題原因:服務端或者客戶端關于傳輸大小的未做設置,maxStringContentLength默認大小為8192,實際傳輸大于8192,由此產生異常。

?

解決方案:

1.確定是客戶端還是服務端的限制。

?

2.在客戶端或服務器的做如下配置:

?

<binding name="xxx" maxReceivedMessageSize="2147483647"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"maxNameTableCharCount="2147483647" />security></binding>

代碼中可修改如下:

MyServiceClient service = null;//MyServiceClient service = new MyServiceClient();try{System.ServiceModel.Channels.CustomBinding bing = new System.ServiceModel.Channels.CustomBinding(new System.ServiceModel.Channels.BindingElement[]{ new BinaryMessageEncodingBindingElement(){ ReaderQuotas= new System.Xml.XmlDictionaryReaderQuotas {MaxDepth=2147483647, MaxStringContentLength=2147483647, MaxArrayLength=2147483647, MaxBytesPerRead=2147483647}},new HttpTransportBindingElement()});bing.Name = "CustomBinding_DataService";EndpointAddress address = new EndpointAddress(http://www.xxx.com/MyService.svc);service = new MyServiceClient(bing, address);}catch (Exception ex){throw ex;}

?


?

總結

以上是生活随笔為你收集整理的The maximum string content length quota (8192) has been exceeded while reading XML data的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。