繁体   English   中英

WCF Web服务无法反序列化,因为最大字符串内容长度配额

[英]WCF Web Service can't deserialize because of maximum string content length quota

我知道这个问题曾经被问过,但是我已经阅读了所有这些问题,并且我相信我已经实施了他们的所有建议,但它们没有帮助。

Fiddler(最好的工具EVER!)显示,整个消息都在到达服务器,因此客户端(及其app.config)无关紧要。

  • 我确保readerquotas / MaxStringContentLength超过8K。
  • 我确保maxItemsInObjectGraph超过8K。
  • 我确保在端点中引用了绑定和行为。
  • 我确保确实连接到了引用的端点(即URL正确)。

错误消息是:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:deal. The InnerException message was 'There was an error deserializing the object of type MYOBJECT. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 38700.'. Please see InnerException for more details

Web配置的相关部分:

<system.serviceModel> <bindings> <basicHttpBinding> <binding name="DefaultBinding"> <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="DefaultEndpointBehavior"> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <services> <service name="DmsIntegrationService"> <endpoint behaviorConfiguration="DefaultEndpointBehavior" binding="basicHttpBinding" bindingConfiguration="DefaultBinding" contract="MYCONTRACT" /> </service> </services> </system.serviceModel>

我知道将所有这些数字提高到int.MaxValue是潜在的DOS风险。 在发布之前,我将降低它们。

尝试这样的事情

<binding name="DefaultBinding" maxBufferPoolSize="524288" maxBufferSize="524288" maxConnections="10" maxReceivedMessageSize="5242880"> <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding>

在这里也参考这个链接

尝试将所有内容放到WCF Web配置中

<system.web>
    <httpRuntime maxRequestLength="5120000" />
</system.web>
  <system.webServer>
    <urlCompression doDynamicCompression="true" doStaticCompression="true" />
    <validation validateIntegratedModeConfiguration="false" />
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1024000000" />
      </requestFiltering>
    </security>
  </system.webServer>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM