I get no error when calling my WCF service methods except in one.
This particular method called SaveTemplate() takes an input of byte[].
I am testing this method with a file of size byte[806803], but ending in an error:
WCF - The remote server returned an unexpected response: (400) Bad Request.*
I have gone through several search results I have found on Google and made some change in app.config according to those, but still getting the error :-(
Here is my WCF Service Library's App.Config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttp" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000"
messageEncoding="Mtom" >
<readerQuotas maxDepth="500000000" maxStringContentLength="500000000" maxArrayLength="500000000"
maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
name="ReportingComponentLibrary.TemplateService">
<endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateService" bindingConfiguration="wsHttp" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateService/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
name="ReportingComponentLibrary.TemplateReportService">
<endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateReportService" bindingConfiguration="wsHttp" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateReportService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ReportingComponentLibrary.TemplateServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
My 50 cents: change the value of the maxRequestLength attribute of the httpRuntime element from 65536 to 2147483647.
Thank you for all help!
It was my ignorance that caused me to take so much time to resolve it.
I had failed to update the config file of my Windows Service with the new Binding configuration. Instead, I was just copying a separate config file in Windows Service directory.
Since you appear to be hosting inside of ASP.NET in IIS, you need to make sure that the request length ASP.NET allows is also set in addition to WCF's various settings. For ASP.NET the setting you're looking for is
maxRequestLength
on thehttpRuntime
element. The default for this setting is only 4MB, so that would explain why you run into an issue.That would look a little something like this for a 512MB maxLength: