Another WCF MaxMessageSize error
So I ran into the classic "Maximum message size exceeded" error with a WCF service I am working on. Strangely though, setting all the message size settings way up as other posts suggest doesn't seem to do anything; I still get the same error.
Here is my server config. The client isn't .net, so there is no client config.
Any ideas?
<services>
<service name="MyService" behaviorConfiguration="HTTPMetadataBehavior">
<endpoint address="http://localhost:2624" binding="webHttpBinding"
bindingConfiguration="WebHttpSettings" contract="IMyService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="HTTPMetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
httpGetBindingConfiguration="" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="WebHttpSettings" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
开发者_运维技巧 </bindings>
You need one more setting in the service behaviour:
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
My guess is your actual service name isn't MyService by rather it is in a namespace.
Assuming you are using .NET 4 the actual service is picking up a default endpoint with the default binding settings or 65536. Change the name in the service element to be the fully qualified type name of the service implementation class
Okay this fix won't work for everyone, but for me I made my configuration the default for webHttp by omitting the name and that worked. Here is the revised config.
<services>
<service name="MyService" behaviorConfiguration="HTTPMetadataBehavior">
<endpoint address="http://localhost:2624" binding="webHttpBinding"
bindingConfiguration="" contract="IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="HTTPMetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
httpGetBindingConfiguration="" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
精彩评论