wcf项目里面,客户端的某个函数执行时可能需要上传13000个字符到服务器。
按照常规的接口+客户端调用写好代码之后,出现了这么个错误:
网上查了很多资料,没有能够一步到位解决问题的。花了2个小时,总算是扁出来了。
需要同时修改客户端的app.config和服务器端的web.config。
客户端app.config(下划线为修改的地方):
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IAAASvc" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:604/AAASvc.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAAASvc" contract="ServiceReference.IQuotSvc" name="BasicHttpBinding_IAAASvc" /> </client> </system.serviceModel>
服务器端的web.config:
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="Custom_Binding_A" maxBufferSize="65536" maxReceivedMessageSize="65536"> <readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"></security> </binding> </basicHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="Custome_Beha_A"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <dataContractSerializer maxItemsInObjectGraph="2147483647"/> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="Custome_Beha_A" name="Eprinter.Quotation.Web.AAASvc"> <endpoint address="" bindingConfiguration="Custom_Binding_A" binding="basicHttpBinding" contract="Eprinter.Quotation.Web.IAAASvc"/> </service> </services>
这里需要另外增加Binding和behavior, 以及service的配置。需要注意的是,service配置里面,上面的name是名称空间.类名,下面的contract为名称空间.接口名。