Returned by the WCF server: (413) Request Entity Too Large, wcfentity

Source: Internet
Author: User

Returned by the WCF server: (413) Request Entity Too Large, wcfentity

We can all guess that the file is too large to pass out of the default WCF range, so we need to modify the file.

Both the server and client must be modified.

First, the client:

<system.serviceModel>        <bindings>            <basicHttpBinding>                <binding name="BasicHttpBinding_ITaskService"  />            </basicHttpBinding>        </bindings>        <client>            <endpoint address="http://localhost:9001/wcf/TaskService.svc"                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITaskService"                contract="BZAService.ITaskService" name="BasicHttpBinding_ITaskService" />        </client>    </system.serviceModel>

  

The above is generated by default by the wcf client. If you need to modify the transfer file size, you need to change it.

<binding name="BasicHttpBinding_ITaskService" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />

  

  2. Server: 
<system.serviceModel>       <services>          <service name="BZACenterService.AssetService.TaskService">        <endpoint address="" binding="basicHttpBinding" contract="BZACenterService.AssetService.ITaskService">          <identity>            <dns value="localhost" />          </identity>        </endpoint>        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />        

The above is the default configuration of the server, we found that there is no bindings, how to set it, the method is to manually add the following on <services>

<bindings>     <basicHttpBinding>        <binding name="LargeDataTransferServicesBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"             transferMode="Streamed" sendTimeout="00:10:00" /></binding>

Then remember to add the property bindingConfiguration = "LargeDataTransferServicesBinding" to the endpoint of the service Force"

The final result is as follows:

<system.serviceModel> <bindings>      <basicHttpBinding>        <binding name="LargeDataTransferServicesBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"                  transferMode="Streamed" sendTimeout="00:10:00"                 />      </basicHttpBinding>    </bindings>       <services>          <service name="BZACenterService.AssetService.TaskService">        <endpoint address="" binding="basicHttpBinding" contract="BZACenterService.AssetService.ITaskService">          <identity>            <dns value="localhost" />          </identity>        </endpoint>        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />        

 Third, test and run

Finally, compile and run the program, and call wcf normally.

 

 

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.