Http://www.cnblogs.com/mingzhe/archive/2009/07/07/1518468.html
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> <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 = "http: // localhost: 22000/service/wcfservice. SVC "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 bindings to specify the maximum data reception:
<Bindings> <basichttpbinding> <binding name = "inherit" 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"/> here, the unit is KB. In this way, MB of files can be uploaded. Of course, it is better to perform multipart transmission for such a large file.