本文介绍了如何使用c#从WCF保存DataBase中的大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,

我收到错误远程服务器返回了意外的响应:(413)请求实体太大。当我试图在数据库中保存超过200 Kb文件时,我在中间层使用WCF。



请分别查看客户端配置和WCF配置:

Hello All,
I am getting error "The remote server returned an unexpected response: (413) Request Entity Too Large." when I am trying to save more than 200 Kb file in database,I am using WCF in middle layer.

Please have a look Client config and WCF config respectively:

<binding name="BasicHttpBinding_IService_User" closeTimeout="00:10:00"
         openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
         textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
         messageEncoding="Text">
         <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
         maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

         <security mode="None">
           <transport clientCredentialType="None" proxyCredentialType="None"
             realm="">
             <extendedProtectionPolicy policyEnforcement="Never" />
           </transport>
           <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>

       </binding>





WCF配置:





WCF Config:

<system.serviceModel>
    
    <services>
      <service name="ServiceUser">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicWithMtom" contract="IService_User"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:49283/Cmplreporton_ITC_Admin_WCF/Service_User.svc"/>
          </baseAddresses>
        </host>
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="BasicWithMtom" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          textEncoding="utf-8"  useDefaultWebProxy="true"
          messageEncoding="Text" transferMode="Streamed">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="">
              <extendedProtectionPolicy policyEnforcement="Never" />
            </transport>
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>

        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>

推荐答案



这篇关于如何使用c#从WCF保存DataBase中的大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 20:19