1. 程式人生 > >格式化程式嘗試對訊息反序列化時引發異常: 嘗試對引數 http://tempuri.org/ 進行反序列化時出錯: GetLzdtArticleResult。InnerException 訊息是“反序

格式化程式嘗試對訊息反序列化時引發異常: 嘗試對引數 http://tempuri.org/ 進行反序列化時出錯: GetLzdtArticleResult。InnerException 訊息是“反序

當遇到這個錯誤的時候鬱悶了好長時間報錯是字串長度過大可是修改了MaxStringContentLength”屬性的值卻不起作用最後才發現還是因為配置檔案配置的問題在服務端

格式化程式嘗試對訊息反序列化時引發異常: 嘗試對引數 http://tempuri.org/ 進行反序列化時出錯: GetLzdtArticleResult。InnerException 訊息是“反序列化物件 屬於型別 lzdt.DTO.Dtolzdt[] 時出現錯誤。讀取 XML 資料時,超出最大字串內容長度配額 (8192)。通過更改在建立 XML 讀取器時所使用的 XmlDictionaryReaderQuotas 物件的 MaxStringContentLength 屬性,可增加此配額

儘管我設定了“MaxStringContentLength”屬性的值,但有這個錯誤...後來發現在服務端終結點配置上必須增加繫結配置屬性 bindingConfiguration="BasicHttpBinding_NewBind"才起作用 ,恍然大悟,記錄部落格備忘決不允許再犯這樣低階的錯誤!!!!!!!!

<services>
      <service name="Gps.OpenAPI.WebService.GpsWebService"  behaviorConfiguration="liuyaokai_behavior">
        <host>
          <baseAddresses>
            <add baseAddress="

http://localhost:13700/GpsWebService.svc"/>
          </baseAddresses>
        </host>
        <endpoint name="BasicHttpBinding_IGpsWebService" address="" binding="basicHttpBinding" contract="Gps.OpenAPI.WebService.IGpsWebService" bindingConfiguration="BasicHttpBinding_NewBind"   />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services> 

 <basicHttpBinding>
      <binding name="BasicHttpBinding_NewBind" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="5242880000" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="409600" maxNameTableCharCount="2147483647" />
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
          <message clientCredentialType="UserName" algorithmSuite="Default"/>
        </security>
      </binding>
      </basicHttpBinding>