调用WCF时,调用已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定。...

本文介绍了解决WCF服务中遇到的消息大小限制问题的方法。通过调整客户端配置文件中的maxReceivedMessageSize等属性,可以有效避免因消息过大导致的服务调用失败。文中详细展示了具体的XML配置示例。

解决方案:

其实只要在客户端配置文件中加上如下紫色粗体属性(

maxReceivedMessageSize):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>

      
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true" messageEncoding="Text">
                    <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
                <binding name="BasicHttpBinding_IService11" maxReceivedMessageSize="2147483647" />
                <binding name="BasicHttpBinding_IService2" />
              <!--解决- 调用已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定。只要客户端配置这个就够了。2017-10-20 23:45-->
                <binding name="BasicHttpBinding_IService12" maxBufferPoolSize="2147483647"
                    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:5104/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService11" contract="ServiceReference1.IService1"
                name="BasicHttpBinding_IService1" />
            <endpoint address="http://localhost:5104/Service2.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService2" contract="ServiceReference2.IService2"
                name="BasicHttpBinding_IService2" />
            <endpoint address="http://192.168.0.102/winWCF/Service1.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService12"
                contract="ServiceReference3.IService1" name="BasicHttpBinding_IService11" />
        </client>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

 

服务端不用配置如下的节点:

如果还是不对,则可以用vs中工具栏下的==》WCF服务配置编辑器打开客户端.cofig查看是否正确配置。

 

转载于:https://www.cnblogs.com/longdb/p/7702623.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值