简体   繁体   English

WCF(413)请求实体太大-也在更改配置后

[英]WCF (413) Request Entity Too Large - also after changing configuration

I have a problem connected with error 413 Request Entity Too Large when I try to send bigger data through WCF service. 当我尝试通过WCF服务发送更大的数据时,出现与错误413 Request Entity Too Large有关的问题。 I changed configuration adding maxReceivedMessageSize and some others but it didn't help. 我更改了配置,添加了maxReceivedMessageSize和其他一些参数,但这没有帮助。 Below I paste my config: Config on server side: 我在下面粘贴我的配置:在服务器端配置:

<system.serviceModel>
<services>
  <service behaviorConfiguration="BasicBehavior" name="xxx">
    <endpoint address="" behaviorConfiguration="EndpointBehavior" bindingConfiguration="BasicBinding"
      binding="basicHttpBinding" name="GenerateDocuments" contract="xxx" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="BasicBinding" sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
       <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        <security mode="None">
        <transport clientCredentialType="None"/>
        </security>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="BasicBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="EndpointBehavior">
    </behavior>
  </endpointBehaviors>
</behaviors>

And here is my binding config on client side (on client config is created programmatically): 这是我在客户端的绑定配置(在客户端配置上以编程方式创建):

BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "BasicBinding";
binding.SendTimeout = new TimeSpan(0, 5, 0);
binding.Security.Mode = BasicHttpSecurityMode.None;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.MaxBufferPoolSize = 2147483647;
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.ReaderQuotas.MaxDepth = 2000000;
binding.ReaderQuotas.MaxStringContentLength = 2147483647;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;

And finally client calls service: 最后,客户致电服务:

GenerateDocumentsClient service = new GenerateDocumentsClient(ConnectionManager.GetBinding(), ConnectionManager.GetEndpoint(MainFields.DatabaseRegister))

I also changed attribute uploadReadAheadSize but it also didn't help. 我还更改了属性uploadReadAheadSize,但它也没有帮助。 I have no idea what can I do to make it right. 我不知道该怎么做才能正确。 I will be grateful for any help. 我将不胜感激。

try this in the Service web.config(befor system.serviceModel): 在服务web.config(befor system.serviceModel)中尝试以下操作:

  <system.web>
       <httpRuntime maxRequestLength="2147483647" />
  </system.web>
     <system.webServer>
     <security>
         <requestFiltering>
                <requestLimits maxAllowedContentLength="2147483647"></requestLimits>
          </requestFiltering>
      </security>
  </system.webServer>

OK, this topic can be closed. 好的,可以关闭此主题。 I found really stupid reason why I couldn't do that so the problem is solved. 我发现了我无法做到这一点的真正愚蠢的原因,因此问题得以解决。

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

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