"Go" WCF Transfer Big Data settings

Source: Internet
Author: User

When transmitting large data (>65535B) from the client to the WCF server, the discovery program jumps directly from the reference BeginInvoke to the EndInvoke, without entering the service's actual logic on the server, Suspicion is caused by excessive data exceeding the limit.

The problem is that the data I actually send is just received from the WCF server, and one goes, and the amount of data is not very different.

And then found that the client and the server are actually using different configurations, for the client, The System.ServiceModel section of the Servicereferences.clientconfig file that is automatically generated when you add ServiceReference has this setting:

<Bindings> <BasicHttpBinding> <binding name= "basichttpbinding_wcfservice "maxbuffersize=" 2147483647 "maxreceivedmessagesize=" 2147483647 "> < Security mode=" /> </binding> </ basichttpbinding></ bindings>        

Then apply the binding Configuration in the client section:

<client > <endpoint address
        
         = "
         http://localhost:22000/service/wcfservice.svc" binding< Span style= "color:blue;" >= "basichttpbinding" bindingconfiguration = "basichttpbinding_wcfservice" = "wcfservicereference.wcfservice" name= "basichttpbinding_wcfservice" />             
        
</Client> 

The maximum cache bytes and the maximum number of bytes accepted are specified in the binding, which is equal to the size of 2G! Unless a series of serials is passed, it is generally sufficient.

On the server side, the Web. config file, the bindings section is empty, and the service does not specify the Bindingconfiguration attribute, then they use the default size of 65535.

Problem finding, the solution is relatively easy:

In the Bindings section, add a new binding setting that specifies the maximum accepted data:

<Bindings> <BasicHttpBinding> <binding name= "largedatatransferservicesbinding" = "2147483647" messageencoding=" transfermode= "streamed" = "00:10:00" /> </basichttpbinding></ bindings>        

Then specify the Bindingconfiguration attribute to the appropriate service:

<ServiceBehaviorconfiguration="Server.Service.WcfServiceBehavior "Name="Server.Service.WcfService "> <EndpointAddress=""Binding= "basichttpbinding" = "largedatatransferservicesbinding" Span style= "color:red;" >contract= "server.service.wcfservice" /> <endpoint address< Span style= "color:blue;" >= "mex" binding= "mexhttpbinding "contract=" /></service >             

This makes it possible to send large enough data from the client.

P.S.:

. NET can only pass 4M of files by default, so even if you set the configuration on both ends of WCF, or not the. NET limit, if you want to transfer large files, you also need to add the system.web section

    <httpruntimemaxrequestlength= "102400/>  

Here the unit is KB, so you can transfer 100M files. Of course, such a large file, preferably segmented transmission is better.

Ext.: http://www.cnblogs.com/smjack/archive/2009/02/27/1399353.html

<wshttpbinding>:http://msdn.microsoft.com/zh-cn/library/ms731299.aspx

"Go" WCF Transfer Big Data settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.