WCF服务maxReceivedMessageSize basicHttpBinding问题

我似乎无法让我的WCF服务接受大量的数据发送到它。

我为客户端configuration了maxReceivedMessageSize,可以接收大量数据,这不是问题。 它将数据发送到服务。

我试图configuration服务,但没有任何运气。 这是我的web.config:

<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true"/> </system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false" /> <serviceDiscovery /> </behavior> </serviceBehaviors> </behaviors> <services> <service name="Service.IService"> <clear /> <endpoint binding="basicHttpBinding" bindingConfiguration="MessageSizeBasic" contract="Service.IService" /> </service> </services> <bindings> <basicHttpBinding> <binding name="MessageSizeBasic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding> </basicHttpBinding> <webHttpBinding> <binding name="MessageSizeWeb" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" /> </webHttpBinding> </bindings> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration> 

从绑定中删除名称将使其适用于所有端点,并应产生所需的结果。 如此:

 <services> <service name="Service.IService"> <clear /> <endpoint binding="basicHttpBinding" contract="Service.IService" /> </service> </services> <bindings> <basicHttpBinding> <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding> </basicHttpBinding> <webHttpBinding> <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" /> </webHttpBinding> </bindings> 

另请注意,我从端点节点中删除了bindingConfiguration属性。 否则,你会得到一个例外。

在这里也find了同样的解决scheme: 在WCF中有大量请求的问题

您的服务类的名称是否真的IService (在服务名称空间上)? 你可能原来是在<service>元素的name属性中的服务类的name不匹配。

当使用HTTPS而不是ON绑定时,将其与httpsTransport标签绑定:

  <binding name="MyServiceBinding"> <security defaultAlgorithmSuite="Basic256Rsa15" authenticationMode="MutualCertificate" requireDerivedKeys="true" securityHeaderLayout="Lax" includeTimestamp="true" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10" requireSignatureConfirmation="false"> <localClientSettings detectReplays="true" /> <localServiceSettings detectReplays="true" /> <secureConversationBootstrap keyEntropyMode="CombinedEntropy" /> </security> <textMessageEncoding messageVersion="Soap11WSAddressing10"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> </textMessageEncoding> <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" requireClientCertificate="false" /> </binding>