WCF服务端返回:(413) Request Entity Too Large
生活随笔
收集整理的這篇文章主要介紹了
WCF服务端返回:(413) Request Entity Too Large
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
出現(xiàn)這個原因我們應(yīng)該都能猜測到,文件傳出過大,超出了WCF默認(rèn)范圍,那么我們需要進(jìn)行修改。
服務(wù)端和客戶端都需要修改。
第一、客戶端:
<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>
上面是wcf客戶端默認(rèn)生成的,如需要修改傳輸文件大小,需要一下改動
<binding name="BasicHttpBinding_ITaskService" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
第二、服務(wù)端:
<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" /><host><baseAddresses><add baseAddress="http://localhost:8733/Design_Time_Addresses/BZACenterService.AssetService/TaskService/" /></baseAddresses></host></service> </services><behaviors><serviceBehaviors><behavior> <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="False" /></behavior></serviceBehaviors></behaviors></system.serviceModel>
上面是服務(wù)端默認(rèn)配置,我們發(fā)現(xiàn)并沒有bindings,如何設(shè)置那,方法是手動在<services>上增加如下
<bindings><basicHttpBinding><binding name="LargeDataTransferServicesBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"transferMode="Streamed" sendTimeout="00:10:00" />
</binding>
然后記得在在service 力的endpoint ?增加屬性?bindingConfiguration="LargeDataTransferServicesBinding"
最終如下:
<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" /><host><baseAddresses><add baseAddress="http://localhost:8733/Design_Time_Addresses/BZACenterService.AssetService/TaskService/" /></baseAddresses></host></service> </services><behaviors><serviceBehaviors><behavior> <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="False" /></behavior></serviceBehaviors></behaviors></system.serviceModel>
?第三、測試運行
? ? ? 最后編譯運行,正常調(diào)用wcf了。
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/clc2008/p/7250142.html
總結(jié)
以上是生活随笔為你收集整理的WCF服务端返回:(413) Request Entity Too Large的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 情开头的成语有哪些啊?
- 下一篇: 我有凯撒,格雷夫,卧龙,白虎,天宇圣龙,