maxreceivedmessagesize error even with all configurations - wcf

I have a problem with the MaxReceivedMessageSize attribute, I have all the settings done, but I keep getting the message related to value exceeded (65536)
Can you help me identify the problem in the configuration?
Thank you
This is my web.config file
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Binding1" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<security mode="None" />
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="saam.mdlw.srv.aep.SerBehavior" name="saam.mdlw.srv.aep.aep">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1" behaviorConfiguration="saam.mdlw.srv.aep.EndBehavior" contract="saam.mdlw.srv.aep.Isrv_aep" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="saam.mdlw.srv.aep.EndBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="saam.mdlw.srv.aep.SerBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>

Related

Upload greater than 8 MB streams through WCF Service

I'm trying to upload photo(attachment stream) through window service , using REST configuration (webHttpBinding), but I get this exception
here is the binding configuration I used (I tried all of them and the error still as it )
<webHttpBinding>
<binding name="maxRequest" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport"></security>
</binding>
<binding name="maxRequestBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport">
</security>
</binding>
<binding name="BasicHttpBinding_IFileService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" useDefaultWebProxy="true"
>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport"></security>
</binding>
I had also tried the solution for IIS posted here
https://techcommunity.microsoft.com/t5/iis-support-blog/solution-for-request-entity-too-large-error/ba-p/501134
however, all of the above doesn't work.
here is my endpoint behavior
<endpointBehaviors>
<behavior name="rest">
<webHttp faultExceptionEnabled="true" helpEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="1365536" />
</behavior>
</endpointBehaviors>
here is the contract
and For more information the image size is just 100KB.
WCF default transmission message size is 64KB, you need to use MaxReceivedMessageSize to set the transmission message size.
<system.serviceModel>
<services>
<service name="ConsoleApp1.RawDataService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8012/ServiceModelSamples/service"/>
</baseAddresses>
</host>
<endpoint address=""
binding="webHttpBinding"
contract="ConsoleApp1.IReceiveData"
behaviorConfiguration="ESEndPointBehavior" bindingConfiguration="RestfullwebHttpBinding"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="RestfullwebHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
You need to apply RestfullwebHttpBinding to the endpoint.
Feel free to let me know if the problem persists.

WCF: 413 Request Entity Too Large

I've read many posts about it but I don't know what happens with my web.config.
This is de web.config code:
<system.serviceModel>
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding0"
contract="Service.IService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" closeTimeout="00:05:00" openTimeout="00:05:00"
sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="NewBinding1" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
I'm so sorry but I am not familiarized with the web.conf files. I've read that I have to set the maxReceivedMessageSize, but I've done it and I've received the same error.
I'm editing the file with Microsoft Service Configuration Editor.
I've tried with basicHttpBinding and without webHttpBinding, but does not work.
Every time I call the WCF, I receive the same error.
Trying in SOAPUI, when the message size is less than 65537, it works. When the message size is more than 65536, it does not work.
Thaks in advance.
Carles
Here is the working code of app.config-
<bindings>
<webHttpBinding>
<binding name="myBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed" >
<readerQuotas maxDepth="64" maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ForecastREST_API.RESTServiceImplBehavior" name="ForecastREST_API.RestServiceImpl">
<endpoint address="http://localhost:59624/RestServiceImpl.svc" binding="webHttpBinding" contract="ForecastREST_API.IRestServiceImpl" behaviorConfiguration="Web" bindingConfiguration="myBinding">
</identity>
</endpoint>
<endpoint address="mex" binding="webHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Web">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
<dispatcherSynchronization asynchronousSendEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ForecastREST_API.RESTServiceImplBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
The maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" and the bindingConfiguration="myBinding" is important only in service endpoint section and the bindingName is needed also in my project.

Maximum number of items that can be serialized or deserialized in an object graph is '32767'

I am getting an error: Maximum number of items that can be serialized or deserialized in an object graph is '32767'. Change the object graph or increase the MaxItemsInObjectGraph quota.
Here is what my server-side and client-side web.config looks like:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="USMC.Playbook.DataService.PlaybookService">
<endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding" bindingConfiguration="App" contract="AppService.IAppService" name="App"/>
</client>
The request is only pulling items so it shouldnt be throwing an error. Can anyone see what is causing this error?
Put this configuration in your service config,
The thing you have missed in your config is the service behaviour,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="USMC.Playbook.DataService.PlaybookService" behaviorConfiguration="SilverlightWCFLargeDataApplication">
<endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding" bindingConfiguration="App" contract="AppService.IAppService" name="App"/>

WCF: The InnerException message was 'Maximum number of items that can be > serialized or deserialized in an object graph is '65536'

I know many have posted the solutions about this, I have tried all of solutions that were posted on the internet but those didn't work for me. In this scenario, I want to consume WCF service from a SharePoint timer job.
I am constantly getting the issue stated below:
The formatter threw an exception while trying to deserialize the
message: There was an error while trying to deserialize parameter
http://test/MyEntry/2010/03:GetResult. The InnerException message
was 'Maximum number of items that can be serialized or deserialized in
an object graph is '65536'. Change the object graph or increase the
MaxItemsInObjectGraph quota. '. Please see InnerException for more
details.
My Server side web.config for SVC is:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IVerksamhetService_server" closeTimeout="10:10:00"
openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false" >
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="SomeService.DeluxeEntryBehavior" name="SomeService.DeluxeEntry">
<endpoint address="" binding="wsHttpBinding" contract="SomeService.IVerksamhetService" bindingConfiguration="WSHttpBinding_IVerksamhetService_server" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SomeService.DeluxeEntryBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
My client side config (I added this configuration in OWSTIMER.EXE.CONFIG file)
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IVerksamhetService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10: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 maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceViewEventBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://testserver.ivodmz.za/TestService/MyWCF.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IVerksamhetService"
contract="IVerksamhetService" behaviorConfiguration= "ServiceViewEventBehavior" name="WSHttpBinding_IVerksamhetService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Update:
I have WCF endpoint setting the limit to 65536 but how can make the endpoint to ignore dll behavior and use what is specified in the XML configuration ?
add behavior to congig and aad it to service
<serviceBehaviors>
<behavior name="DefaultBehavior" MaxItemsInObjectGraph="2147483647">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>

WCF: A registration already exists for URI

I have the below in my WCF Web.Config. When I try to access the WCF service I am getting the "A registration already exists for URI" error. The WCF Service is hosted in an SSL enviroment.
Can anyone help please?
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="52428800" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="SOAPBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="52428800" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="wsHTTPBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior name="jsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WsBehavior">
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://*******.com/*****/*****.svc" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="***.***" behaviorConfiguration="WsBehavior">
<endpoint behaviorConfiguration="wsHTTPBehavior" binding="basicHttpBinding" contract="***.***" bindingConfiguration="WSBinding" />
<endpoint address="xml" behaviorConfiguration="jsonBehavior" binding="webHttpBinding" contract="***.***" bindingConfiguration="SOAPBinding" name="SOAP" />
</service>
</services>
Added /mex after .svc extension and worked
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://*******.com/*****/*****.svc/mex" />
Take a look at a-registration-already-exists-for-uri-when-hosting-same-service-for-https-and. It seems like the same problem...
Or this one: wcf-inner-exception-message-a-registration-already-exists-for-uri-net-tcp