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.