The maximum message size quota for incoming messages has been exceeded - wcf

I would like to ask for your help because sometimes I get an error message when I call a service : 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.
On one side :
<bindings>
<basicHttpBinding>
<binding name="BasicHttp" bypassProxyOnLocal="true"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WebHttp" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx:7575/MyRequest.svc" behaviorConfiguration="webhttp"
binding="webHttpBinding" bindingConfiguration="WebHttp"
contract="MyService.Service.Contract.IRequestService" name="MyServiceEndpoint" />
</client>
on the other side (xxx) :
<system.serviceModel>
<services>
<service name="MyService.Service.RequestService" behaviorConfiguration="ServiceEndpointBehavior">
<endpoint address="" binding="webHttpBinding" contract="MyService.Service.Contract.IRequestService" behaviorConfiguration="RestEndPointBehavior" bindingConfiguration="WebHttp"/>
</service>
</services>
<bindings>
<basicHttpBinding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WebHttp" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32" maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
Jojo
I tried several things following the different topics with the same error on "stackoverflow" but nothing works. Thanks in advance

As far as I know, if increasing this value alone doesn't work you may also increase the value of httpRuntime.
If this doesn't work, try BasicHttpBinding.

Related

Still receiving (413) Request Entity Too Large from WCF

I have looked at most of the questions that relate to this issue and none of the solutions are working. The binds that I have are listed below...
Server
<basicHttpBinding>
<binding name="UploadSoap" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport"></security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="UploadSoapWeb" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</webHttpBinding>
<client>
<endpoint address="https:.../upload.asmx" binding="webHttpBinding" bindingConfiguration="UploadSoapWeb" contract="Upload.UploadSoap" name="UploadSoap" />
</client>
Client
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_service" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://.../service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_service"
contract="HH.service" name="BasicHttpBinding_service" />
</client>
I have tried both the basic binding and the web binding but I'm still receiving the error message.
Thanks
You haven't set an explicit binding for your service so it will default to basicHttpBinding with default configuration values. The default value for maxReceivedMessageSize will be 64KB.
Keep in mind that maxReceivedMessageSize is only applicable for the message receiver and not the message sender. The client does not need to set these values if it is sending a large message.
Update your server side binding to the following:
<basicHttpBinding>
<!-- Unnamed (default) binding-->
<binding maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text" /> <!-- Consider using Mtom if you're transfering binary data-->
<binding name="UploadSoap">
<security mode="Transport"></security>
</binding>
</basicHttpBinding>
<client>
<endpoint address="https:.../upload.asmx"
binding="basicHttpBinding"
bindingConfiguration="UploadSoap"
contract="Upload.UploadSoap" name="UploadSoap" />
</client>
The unnamed binding will provide the default values for any endpoint, server or client, using the basicHttpBinding without a bindingConfiguration.
I've assumed that your clients are not receiving a large message in response.
If you're receiving the 413 error from the service, then the problem appears to be that your service config does not have any explicitly defined service endpoints, so the binding configuration that you've created isn't being used.
You need to add a <services> section to your service config, like this:
<services>
<service name="YourServiceName">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="UploadSoap"
contract="YourContractName" />
</service>
</services>
As currently posted, there is nothing that tells WCF to use your defined binding configuration for the service, so by default out of the box WCF will use basicHttpBinding with the default (lower) values.
A second way to resolve this issue is to define a binding configuration and set it as the default for that type of binding by omitting the name attribute, like this:
<binding maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport"></security>
</binding>
I generally prefer the first method (setting an explicit service endpoint), but either should work.

How do I setup config files for WCF Data Service (odata) with EF 6

I have a data service up and running, but I'm getting this error:
The remote server returned an error: (413) Request Entity Too Large.
I have tried a number of things to fix this with no luck.
I have set the uploadReadAheadSize on the Web Site and the Data Service in IIS to the max setting.
I have also tried a number of different setups for the config files.
Here is the current app.config for the client:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILogging" />
<binding name="WCFHttpBinding"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647"
maxDepth="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WCFWebBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/PSIDataService/PSIWcfDataService.svc"
binding="webHttpBinding" bindingConfiguration="WCFWebBinding"
name="WCFWebBinding" contract="*"/>
</client>
I have tried both bindings, WCFWebBinding and WCFHttpBinding.
Here is the web service web.config.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="WCFHttpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WCFWebBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/PSIDataService/PSIWcfDataService.svc"
binding="basicHttpBinding"
bindingConfiguration="WCFHttpBinding"
name="WCFHttpBinding"
contract="*"/>
</client>
Again, I have tried both bindings. I don't know what else can be done. Any help would be great.
I have found a solution to this problem. The web.config must have a service added that names the service and has a contract set to "System.Data.Services.IRequestHandler"
<system.serviceModel>
<services>
<service name="PSIDataService.PSIWcfDataService">
<endpoint bindingConfiguration="msgSize"
address=""
binding="webHttpBinding"
contract="System.Data.Services.IRequestHandler"/>
</service>
</services>
My system complained about both the name of the service and the contract (attribute is invalid warnings). The namespace of my service is PSIDataService and the class name is PSIWcfDataService, so I ignored the complaint. The contract name had the same warning. I knew the interface existed, so I ignored that warning, too.
A webHttpBinding is also required.
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILogging" />
</basicHttpBinding>
<webHttpBinding>
<binding name="msgSize" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</webHttpBinding>
</bindings>
I got the idea for this fix from Malvin Ly (malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize) So thanks Malvin! I don't like the warnings, but this solved my problem.

The maximum nametable character count quota (16384) has been exceeded

I've just increased the number of methods in my ServiceContract. when I update the Service Reference in Visual Studio I get the message:
Metadata contains a reference that cannot be resolved:
'net.tcp://xxxxx.com:8002/DataQueryService/mex'.
There is an error in the XML document.
The maximum nametable character
count quota (16384) has been exceeded while reading XML data. The
nametable is a data structure used to store strings encountered during
XML processing - long XML documents with non-repeating element names,
attribute names and attribute values may trigger this quota. This
quota may be increased by changing the MaxNameTableCharCount property
on the XmlDictionaryReaderQuotas object used when creating the XML
reader.
The original server side config was:
<services>
<service behaviorConfiguration="XXXXX.DataQueryService.ServiceBehavior" name="XXXXX.DataQueryService.QueryService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://xxxxx.com:8002/DataQueryService" />
</baseAddresses>
</host>
<endpoint name="MexEndpoint" address="mex" binding="customBinding" bindingConfiguration="unsecureTcpMex" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<customBinding>
<binding name="unsecureTcpMex">
<tcpTransport portSharingEnabled="True" />
</binding>
</customBinding>
</bindings>
which I modified to:
<bindings>
<customBinding>
<binding name="unsecureTcpMex">
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<tcpTransport portSharingEnabled="True" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
What other changes do I need to make to my config to get this working?
Update
Following #Chris's advice I tried updating the config file for SVCUtil. I added a name to my endpoint so that it would match (updated above). The SvcUtil.config is now as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="unsecureTcpMex">
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint binding="customBinding" bindingConfiguration="unsecureTcpMex"
contract="IMetadataExchange"
name="MexEndpoint" />
</client>
</system.serviceModel>
</configuration>
<binding name="NameSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="1638400" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
Take a look to this line: maxNameTableCharCount="1638400"
I don't suppose its practical to split up the operations into multiple contracts? Mind if I ask how many service operations we're talking about?
Have you tried the solutions in this post?
http://social.msdn.microsoft.com/Forums/vstudio/en-US/17592561-c470-452a-a52c-2a5a2839582c/metadataexchangeclient-and-nametable-character-count-quota
Among other suggestions are using the Discovery protocol to read metadata, which does not have any reader quotas:
http://msdn2.microsoft.com/en-us/library/system.web.services.discovery.discoveryclientprotocol.aspx
The solution at the bottom suggests you change the default reader quotas in code before starting the service. I believe this would have to be done in a custom ServiceHost factory. Please let me know if you would assistance with that.
Hope this helps.
This should help:
http://geekswithblogs.net/claraoscura/archive/2007/08/20/114806.aspx
appears that the solution is to create a config file for svcutil and place it in the same folder as it.
Try setting the new value for the MaxNameTableCharCount property programmatically:
Binding binding = endpoint.Binding;
XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas();
myReaderQuotas.MaxStringContentLength = something;
myReaderQuotas.MaxArrayLength = something;
myReaderQuotas.MaxBytesPerRead = something;
myReaderQuotas.MaxDepth = something;
myReaderQuotas.MaxNameTableCharCount = something;
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, myReaderQuotas, null);
Note: you have to set it BEFORE the client proxy and/or service host are created. Once created, they can't be changed.

Error with WCF configuration for MaxReceivedMessageSize

I am getting the following error when calling my service;
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.
The configuration of the service is;
<bindings>
<basicHttpBinding>
<binding name="basic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Company.Product.Service.FileManager.IFileManager">
<endpoint binding="basicHttpBinding" bindingConfiguration="basic" name="FileManager" bindingNamespace="Company.Product.FileManager.FileManagerService" contract="Company.Product.Service.FileManager.IFileManager" />
<host>
<baseAddresses>
<add baseAddress="http://filemanager.dev.v7.services.Company.net" />
</baseAddresses>
</host>
</service>
</services>
As you can see, I have adjusted the settings accordingly, so not sure why I am still getting this error.
Client Configuration;
<bindings>
<basicHttpBinding>
<binding name="basic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://filemanager.dev.v7.services.Company.net/service.svc" binding="basicHttpBinding" bindingConfiguration="basic" contract="Company.Product.Service.FileManager.IFileManager" name="FileManager"/>
</client>
Update
Changing the service configuration to this (removed the binding name) and this now works, but why would it not work with a named configuration;
<bindings>
<basicHttpBinding>
<binding name="" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
You have to change the app.config of your client as well.
Edit:
If you leave the name attribute empty it will be applied to every binding of the type that is not named. If you have a named binding in the config it will only be picked up if it is explicitly referenced by that name.

Issue on max readers quotas in WCF web service

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:GetFileResult. The InnerException message was 'There was an error deserializing the object of type WindowsClient.CloudServiceProxy.GetFileResponse. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 41572.'. Please see InnerException for more details.
I am getting this issue the
sever web.config is
<system.serviceModel>
<services>
<service behaviorConfigura
tion="CloudServiceBehaviour" name="Web.CloudService">
<endpoint name="CloudServiceClientEndPoint" bindingConfiguration="CloudBindingConfig" address="http://localhost:53243/CloudService.svc" binding="wsHttpBinding" contract="Web.ICloudService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CloudServiceBehaviour">
<serviceMetadata httpGetEnabled="True" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="CloudBindingConfig" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
and the client web.config is ,
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="CloudServiceClientEndPoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:30:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:53243/CloudService.svc" binding="wsHttpBinding"
contract="CloudServiceProxy.ICloudService" name="CloudServiceClientEndPoint" />
</client>
</system.serviceModel>
Since the error is while deserializing the GetFileResponse object, that tells you the problem is in the client-side stack.
Your client side binding is using the default configuration for wsHttpBinding because you have omitted to specify the bindingConfiguration name on the endpoint. Try adding bindingConfiguration="CloudServiceClientEndPoint" to the endpoint element and then your large values for the readerQuotas settings will be picked up.