zoukankan      html  css  js  c++  java
  • WCF已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <configuration>
     3   <connectionStrings>
     4     <add name="connStr" connectionString=""/>
     5   </connectionStrings>
     6   <appSettings>
     7     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
     8   </appSettings>
     9   <system.web>
    10     <compilation debug="true" targetFramework="4.5" />
    11     <httpRuntime targetFramework="4.5"/>
    12   </system.web>
    13   <system.serviceModel>
    14     <behaviors>
    15       <serviceBehaviors>
    16         <!--<behavior>
    17           --><!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false --><!--
    18           <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
    19           --><!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --><!--
    20           <serviceDebug includeExceptionDetailInFaults="false"/>
    21         </behavior>-->
    22         <behavior name="MyBehavior">
    23           <serviceMetadata httpGetEnabled="true"/>
    24           <serviceDebug includeExceptionDetailInFaults="true"/>
    25         </behavior>
    26       </serviceBehaviors>
    27     </behaviors>
    28     <protocolMapping>
    29       <add binding="basicHttpsBinding" scheme="https" />
    30     </protocolMapping>
    31     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    32     <services>
    33       <service behaviorConfiguration="MyBehavior" name="WcfService.Service1">
    34         <endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"
    35           contract="WcfService.IService1" />
    36         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    37       </service>
    38     </services>
    39     <bindings>
    40       <basicHttpBinding>
    41         <binding name="NewBinding0"
    42                  closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
    43                  maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
    44                  messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
    45           <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
    46           <security mode="None" />
    47         </binding>
    48       </basicHttpBinding>
    49     </bindings>
    50     
    51   </system.serviceModel>
    52   <system.webServer>
    53     <modules runAllManagedModulesForAllRequests="true"/>
    54     <!--
    55         若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
    56         在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
    57       -->
    58     <directoryBrowse enabled="true"/>
    59   </system.webServer>
    60 
    61 </configuration>
    服务器Web.config
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <configuration>
     3   <configSections>
     4   </configSections>
     5   <connectionStrings>
     6   
     7   </connectionStrings>
     8   <appSettings>
     9    
    10   </appSettings>
    11   <system.serviceModel>
    12     <bindings>
    13       <basicHttpBinding>
    14         <binding name="BasicHttpBinding_IService1"  maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
    15         
    16       </basicHttpBinding>
    17     </bindings>
    18     <client>
    19       <endpoint address="http://localhost:16583/Service1.svc" binding="basicHttpBinding"
    20         bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceData.IService1"
    21         name="BasicHttpBinding_IService1" />
    22     </client>
    23   </system.serviceModel>
    24 
    25 </configuration>
    客户端App.config

    客户端调用的时候加上这一段代码即可:

    ServiceData.Service1Client client = new ServiceData.Service1Client();
    (client.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
    (client.Endpoint.Binding as BasicHttpBinding).MaxBufferPoolSize = int.MaxValue;
    (client.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;

  • 相关阅读:
    [hibernate]org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter
    [extjs] extjs 5.1 API 开发 文档
    [java] Unsupported major.minor version 51.0 错误解决方案
    [kfaka] Apache Kafka:下一代分布式消息系统
    [spring] org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljav 解决
    [spring] 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾
    [java] java 中Unsafe类学习
    [java] java 线程join方法详解
    [java] jstack 查看死锁问题
    ORACLE DG之参数详解
  • 原文地址:https://www.cnblogs.com/riddly/p/4284451.html
Copyright © 2011-2022 走看看