We have an interesting problem with WCF binding and streaming transfer mode that we cannot solve:
We have an WCF endpoint configured to the streaming transfer mode. The endpoint receives message much larger then the default size (~65 KB). Therefore we have specified larger message size in the maxReceivedMessageSize attribute on the binding tag.
The problem is when we pair up the endpoint and the binding by the bindingConfiguration attribute on the endpoint tag and the name attribute on the binding tag, we receive the following error: "The remote server returned an error: (400) Bad Request".
As soon as we remove both attributes bindingConfiguration and name it works without an error.
Here is the definition of the service endpoint:
<service name="Services.DocumentService" behaviorConfiguration="ServiceBehavior">
<endpoint contract="ServiceContracts.IDocumentService" address="DocumentService"
binding="basicHttpBinding" name="basicHttpBinding"
bindingConfiguration="BindingConfiguration" <---- when this goes away
behaviorConfiguration="ServiceEndpointBehavior"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Documents/"/>
</baseAddresses>
</host>
</service>
Here is the binding configuration:
<binding
name="BindingConfiguration" <---- and when this goes away
transferMode="Streamed" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
So it only works as default binding (without explicitly named key). The strange thing is that we were able to verify by reflection on the Service host that the binding configuration is actually applied (the maxReceivedMessageSize was set correctly) in both scenarios. Could it be a bug in WCF?
The service is self-hosted.
Any ideas are very appreciated?
We have recently found out that the initialization code used explicitly the default settings and thus ignored those in the web.config.
We removed that part of code and the setting from the web.config got applied.
A stupid error.
Thanks everybody for thier answers