When the client transfers large data (> 65535B) to the WCF server, the client reports an error. Remote servers do not respond.
The problem is that the data I actually sent was just received from the WCF server. As a result, the data volume does not differ much.
Then we found that the client and the server actually use different configurations. for the client, the system. serviceModel section in the ServiceReferences. ClientConfig file automatically generated when adding ServiceReference has the following settings:
<Bindings>
<BasicHttpBinding>
& Lt; binding name = "BasicHttpBinding_WcfService" maxBufferSize = "2147483647"
Maxcompute edmessagesize = "2147483647">
<Security mode = "None"/>
</Binding>
</BasicHttpBinding>
</Bindings>
Then apply Binding Configuration in the Client section:
<Client>
<Endpoint address = "www.2cto.com"
Binding = "basicHttpBinding" bindingConfiguration = "BasicHttpBinding_WcfService"
Contract = "WcfServiceReference. WcfService" name = "BasicHttpBinding_WcfService"/>
</Client>
The maximum number of cached bytes and the maximum number of accepted bytes are specified in the Binding, which is equivalent to 2 GB! Unless you pass on a complete series, it is generally enough.
On the server side, the Bindings section in the Web. config file is empty, and the Service does not specify the bindingConfiguration attribute. Therefore, they use the default 65535 size.
It is easier to locate the problem:
Add new Binding settings in the Bindings section. TB specifies the maximum data reception:
<Bindings>
<BasicHttpBinding>
<Binding name = "LargeDataTransferServicesBinding" maxcompute edmessagesize = "2147483647"
MessageEncoding = "Text" transferMode = "Streamed" sendTimeout = "00:10:00"/>
</BasicHttpBinding>
</Bindings>
Then, specify the bindingConfiguration attribute for the corresponding Service:
<Service behaviorConfiguration = "Server. Service. WcfServiceBehavior"
Name = "Server. Service. WcfService">
<Endpoint address = "" binding = "basicHttpBinding" bindingConfiguration = "LargeDataTransferServicesBinding" contract = "Server. Service. WcfService"/>
<Endpoint address = "mex" binding = "mexHttpBinding" contract = "IMetadataExchange"/>
</Service>
In this way, you can send large enough data from the client.
P.S .:
By default, asp.net can only upload 4 m Files. Therefore, although the configuration at both ends of the Wcf is set, it is still unable to exceed.. add
<HttpRuntime maxRequestLength = "102400"/>
The unit here is KB, so that MB of files can be uploaded. Of course, it is better to perform multipart transmission for such a large file.
Author: tbwshc