Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF maxReceivedMessageSize超高设置超过4215_C#_Wcf_App Config - Fatal编程技术网

C# WCF maxReceivedMessageSize超高设置超过4215

C# WCF maxReceivedMessageSize超高设置超过4215,c#,wcf,app-config,C#,Wcf,App Config,我想在WCF客户端的App.config中设置maxReceivedMessageSize 如果maxReceivedMessageSize等于或小于4215,则可以正常工作。尽管将其设置为4216或其上的任何值时,默认值为65536 我的客户代码 <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime versi

我想在WCF客户端的App.config中设置maxReceivedMessageSize

如果maxReceivedMessageSize等于或小于4215,则可以正常工作。尽管将其设置为4216或其上的任何值时,默认值为65536

我的客户代码

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IConexaApiServic" maxReceivedMessageSize="4216" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://svsr02.conexa.local/HelloService/ConexaApiService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IConexaApiServic"
                contract="ConexaApiService.IConexaApiService" name="BasicHttpBinding_IConexaApiService" />
        </client> 
    </system.serviceModel>
</configuration>

以及相关的服务器代码

<basicHttpBinding>
        <binding name="BasicHttpEndpoint_MPSAPIServic" maxReceivedMessageSize="2000000">
          <security mode="TransportWithMessageCredential" />
        </binding>
        <binding name="BasicHttpEndpoint_HelloService" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2000000">

  </binding>
   </basicHttpBinding>

 <service name="IIS_test123.HelloService">
        <endpoint address="ConexaApi" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpoint_HelloService" contract="IIS_test123.IHelloService"></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/API/ConexaApiService" />
          </baseAddresses>
        </host>
      </service>
    </services>


你知道如何解决这个问题吗?

这是可以解释的。如果您查看您的异常:

  • System.ServiceModel.CommunicationException是从客户端引发的异常。它具有来自客户端的maxReceivedMessageSize。一切都很好
  • FaultException:此异常是一个SOAP错误,它将异常从服务传播到客户端应用程序。( ). 所以这个异常实际上来自服务端!maxReceivedMessageSize是默认值,与服务器配置中的maxReceivedMessageSize不对应。 您在客户端中连接到的地址是服务地址,而不是配置的maxReceivedMessageSize,也不是配置为maxReceivedMessageSize=“2000000”的端点地址ConexaApi。这就是您获得默认65536的原因

如果您认为如果增加了异常,则不会增加消息的大小。

如果您在IIS上运行,您是否检查IIS管理器设置?为什么您说“它工作正常”,值为4215,而您的第一个截屏显示了异常?@ PATRIGGAHIDE意味着设置值有效。正如您在第一个屏幕截图中看到的,异常文本中提到的值是4215,而在第二个屏幕截图中提到的值是65536。我注意到客户端和服务配置中的地址不匹配,特别是服务配置指定了一个端口(8733),而客户端不匹配。也许这导致了与默认端点和绑定的一些奇怪的相互作用?