There are multiple related questions on SO (almost same title), none of them helped me to fix my problem. Please do not close my question as duplicate before reading it. Thanks.
I'm currently using WCF to expose a webservice (SOAP, HTTP). It is deployed in IIS Express for now. My problem is, I can't manage to consume my service from my client. My client receives a HTTP Error 400 Bad request
exception.
I've then activated tracing on server side to see what's actually happening, here's what I get:
I've translated the error message into English: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
.
Pretty self-explanatory, actually. As my SOAP message is quite heavy, it probably exceeds the limit of 64KB.
I decided to extends this limit in the binding configuration. So here's my web.config (server side):
<services>
<service name="MyServiceName">
<endpoint binding="basicHttpBinding"
bindingConfiguration="MyBindingConfiguration"
bindingNamespace="http://my_namespace"
contract="XXX.IMyContract" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="MyBindingConfiguration"
allowCookies="true"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32" maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
As you can see, all sizes are set to int.MaxValue
.
I've also modified my client app.config, here it is:
<bindings>
<basicHttpBinding>
<binding name="MyBindingName"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
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:8083/myAddress.svc"
binding="basicHttpBinding"
bindingConfiguration="MyBindingName"
contract="IMyContract"
name="MyBindingName" />
</client>
I then redeployed my service, and the issue was still here (HTTP 400, Bad request
on client side + MaxReceivedMessageSize limited to 65536
on server side).
I then tested my service with a very small SOAP message: everything is perfectly fine. So the problem is really that my message is bigger than 64KB.
I spent 2 hours yesterday trying to figure out what's the problem with my configuration... Probably something obvious, but I can't find...
I've googled a lot about this problem, 95% of time the issue is the developer forgot to specify the bindingConfiguration
attribute in the service endpoint. As you can see in my web.config above, it's OK for me.
Then I've found another question on stackoverflow about the (almost) same issue.
As the author said in his question, setting the name of the binding configuration to string.Empty
"fixes" the problem:
<services>
<service name="MyServiceName">
<endpoint binding="basicHttpBinding"
bindingConfiguration=""
...
<bindings>
<basicHttpBinding>
<binding name=""
...
When using the default binding, everything works fine. I can't just fix my problem using this workaround because I need to specify multiple different binding configurations in the same web.config.
I'm recreating a question here because it's not actually the same conditions: my service is not self-hosted but hosted in IIS Express (or IIS 7.5, tested, same problem).
I've found a similar issue here with a self-hosted service, and the issue was related to this particularity. So I think there is something different between those 2 SO questions.
I guess there's something obviously wrong in my configuration, but I can't find what. Any help appreciated.
Everything seems to be fine at first glance - only point is: the <service name=".....">
attribute must match exactly to your fully-qualified service implementation class (including all namespaces etc.) - is that the case??
I ask because you have contract="XXX.IMyContract"
indicating a namespace, but your <service name="....">
attribute doesn't have any namespace hinted at.