日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

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

發布時間:2025/3/21 asp.net 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

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