简体   繁体   English

远程服务器返回错误:(413)请求实体太大

[英]The remote server returned an error: (413) Request Entity Too Large

Please do NOT delete this message as a duplicate!! 请不要删除此消息作为重复!!

I am writing a WCF service that allows for XML files to be uploaded so that they can be imported into the database. 我正在编写一个WCF服务,该服务允许上载XML文件,以便可以将它们导入数据库。 However I am receiving the above error when I upload a file above the 64k default. 但是,当我上传高于64k默认值的文件时,我收到上述错误。

I have read through all the questions already posted on here about this problem and implemented them but still am facing the same issue. 我已经阅读了有关此问题的所有已发布问题,并已实施,但仍然面临相同的问题。

I have increased all the binding values in my config file (for both the client and server) to accept the maximum size of 2GB. 我增加了配置文件中的所有绑定值(对于客户端和服务器),以接受最大2GB的大小。



    <binding name="BasicHttpBinding_BailiffServices"
                     maxBufferSize="2147483647"
                     maxBufferPoolSize="2147483647"
                     maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647" 
                            maxStringContentLength="2147483647"
                            maxArrayLength="2147483647" 
                            maxBytesPerRead="2147483647"
                            maxNameTableCharCount="2147483647" />
              &ltsecurity mode="None" />

Here are the WCF services that use this binding. 这是使用此绑定的WCF服务。



    <services>
          <service name="ClientService.ClientService">
            <endpoint address="http://subversion/BusinessTier.Services.ClientService.svc"
              binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_BailiffServices"
              name="BasicHttpBinding_IClient" contract="ClientService.IClient" />
          </service>
          <service name="DebtorService.DebtorService">
            <endpoint address="http://subversion/BusinessTier.Services.DebtorService.svc"
              binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_BailiffServices"
              name="BasicHttpBinding_IDebtor" contract="DebtorService.IDebtor" />
          </service>
        </services>

I have also added settings to the config to ensure that IIS is also able to handle large files. 我还向配置添加了设置,以确保IIS也能够处理大文件。



    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <security>
          <requestFiltering allowDoubleEscaping="true">
            <requestLimits maxAllowedContentLength="2147483647"/>
            <fileExtensions allowUnlisted="true"/>
            <verbs allowUnlisted="true"/>
          </requestFiltering>
        </security>
      </system.webServer>

As far as I can see I have amended all the necessary settings to allow my WCF service to accept large files, but none of them have so far worked. 据我所知,我已经修改了所有必要的设置,以允许WCF服务接受大文件,但是到目前为止,这些文件都没有起作用。

Any suggestions would be greatly appreciated. 任何建议将不胜感激。

I found solution to avoid error like 'The remote server returned an unexpected response: (413) Request Entity Too Large.' 我找到了避免诸如“远程服务器返回意外响应:(413)请求实体太大”之类的错误的解决方案。 When using basicHttpBinding in WCF Service Configuration You just need to increase the maximum message length in the Web.config.following way you can update you server web.config and client app.config file for sending large byte array via wcf. 在WCF服务配置中使用basicHttpBinding时,只需要增加Web.config中的最大消息长度即可。可以通过以下方式更新服务器web.config和客户端app.config文件,以通过wcf发送大字节数组。

Include following bindings and behaviors parameters in Web.config 在Web.config中包括以下绑定和行为参数

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding maxReceivedMessageSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false">
  <serviceActivations>
    <add factory ="WebService.NInjectServiceHostFactory" relativeAddress="TestServic.svc" service="WebService.Services.ServiceManager"/>
  </serviceActivations>
</serviceHostingEnvironment>

I have also added binding configuration in client app.config file. 我还在客户端app.config文件中添加了绑定配置。

<system.serviceModel>
<bindings>
<basicHttpBinding>
  <binding name="BasicHttpBinding_IServiceManager"  maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
    <security mode="None"/>
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
  </binding>
</basicHttpBinding>
</bindings>

<client>
<endpoint address="http://localhost:49359/ServiceManager.svc"
 binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPackageManager"
 contract="PackageManager.IPackageManager" name="BasicHttpBinding_IPackageManager" />
</client>

</system.serviceModel>

this will also handle timeout error as well. 这也将处理超时错误。

I've eventually managed to get this working after several hours of head scratching. 经过数小时的头部抓挠之后,我终于设法使它正常工作。 I removed the binding name "BasicHttpBinding_BailiffServices" from both the <binding /> element and the <endpoint /> elements. 我从<binding />元素和<endpoint />元素中删除了绑定名称“ BasicHttpBinding_BailiffServices”。 I stumbled across this solution on the MSDN site. 我在MSDN站点上偶然发现了该解决方案。 Hope this helps someone else. 希望这对其他人有帮助。

暂无
暂无

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

相关问题 远程服务器返回了意外的响应:(413)请求实体太大 - The remote server returned an unexpected response: (413) Request Entity Too Large Exchange Web 服务 - 请求失败。 远程服务器返回错误:(413) 请求实体太大 - Exchange Web Services - The request failed. The remote server returned an error: (413) Request Entity Too Large WCF错误:远程服务器返回错误:(413)请求实体太大 - WCF error: The remote server returned an error: (413) Request Entity Too Large 错误:远程服务器返回了意外的响应:(413)请求实体太大 - Error: the remote server returned an unexpected response: (413) Request Entity Too Large Azure云服务“远程服务器返回错误:(413)请求实体太大。” - Azure Cloud Service “The remote server returned an error: (413) Request Entity Too Large.” 远程服务器返回错误:(413)请求实体太大(尝试“每笔在地球上的解决方案”) - The remote server returned an error: (413) Request Entity Too Large (TRIED EVERY SOLUTION ON EARTH) WCF服务“远程服务器返回错误:(413)请求实体太大。” - WCF Service “The remote server returned an error: (413) Request Entity Too Large.” WCF 4.5:发生意外错误:远程服务器返回了意外响应:(413)请求实体太大 - WCF 4.5: An unexpected error occurred: The remote server returned an unexpected response: (413) Request Entity Too Large WCF 服务与 30mb 输入字符串 - 远程服务器返回错误:(413)请求实体太大 - WCF service with 30mb input string - The remote server returned an error: (413) Request Entity Too Large 文件上传,远程服务器返回错误:(413) Request Entity Too Large - File Upload, The remote server returned an error: (413) Request Entity Too Large
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM