Transferring 5 megabytes file using wcf
I am trying to use wcf for transferring a file larger then 5 mega.(i cant use streeaming for now it demands major changes to running code).
I configured the server and the client to the maximum settings and still i get the exception of maximum length.
Here is my server web.config:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
<service name="xxx.xxx.Service">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="xxx"
contract="xxx.xxx.IService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="b2bservice" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client />
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"开发者_开发问答 />
And here is the client app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="xxx"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="BService.IBService" name="BasicHttpBinding_IService" />
</client>
My trace Logging is:
Maximum request length exceeded.
System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089`
Any thoughts?
You are not resetting the default 4MB limit properly.
Try this: http://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/
Set maxRequestLength
in httpRuntime
section in Web.config
HttpRuntime configuration element
You'll need to increase the max request length by changing the following setting in web.config
<configuration>
<system.web>
<httpRuntime maxRequestLength="32768" />
</system.web>
</configuration>
The value is in KB.
You can use tracing to get more details about your problem and fix it or give use exact error message.
精彩评论