Searched with no luck...
I keep getting
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.
It makes sense, so I go into both Server and client config and make the change:
Client
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileUpload"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" messageEncoding="Text" maxBufferSize="65536" maxReceivedMessageSize="67108864">
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/services/FileUpload.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileUpload"
contract="CFTW.FileUpload.IFileUpload" name="BasicHttpBinding_IFileUpload" />
</client>
</system.serviceModel>
Server
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileUpload"
transferMode="Streamed" messageEncoding="Text" maxBufferSize="67108864" maxBufferPoolSize="67108864" maxReceivedMessageSize="67108864">
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="BasicHttpBinding_IFileUpload">
<endpoint address="~/services/FileUpload.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileUpload"
contract="CFTW.FileUpload.IFileUpload"></endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I'm not sure why it's not working (otherwise I'd fix it:)). It's running on .NET 4.0 RC.
I just ran into this issue. I found that my custom binding did not get applied at all. Then I used name = "" in binding tag. Then everything started working with the new settings. This is due to .NET 4.0 comes with default binding/endpoint/behavior configurations. These default settings have name = "". I just modified the default binding itself. The reason for my custom binding(named) did not get applied is due to the value for the name in <service> tag. It should follow <Namespace.ServiceClassName>.
You need to increase the attribute maxReceivedMessageSize in the client config for the binding. Also, be sure to set the same value for the maxBufferSize. For buffered connection these two values need to be same.
Had the same problem, luckily in a second project and could compare with the working project. The difference was that the working project had additional attributes set in the web.config for the service bindings...
Working sample:
httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
The second project only had:
httpsTransport
Also do a search in your project for 65536 as it is also defined in configuration.svcinfo and configuration91.svcinfo of the service reference.
Related
I have a WCF SOAP service and I am trying to submit a file to the service that is too large (128KB). I have scoured the internet and found many suggestions about adding the maxReceivedMessageSize, maxBufferSize, and other such attributes, but to no avail. I have also added the maxRequestLength to the httpRuntime but that doesn't work either. Not matter what I do I keep getting
HTTP Error 413: Request Entity Too Large.
Error
HTTP Error 413: Request Entity Too Large.
Web Config
<httpRuntime targetFramework="4.5.1" maxRequestLength="1048576"/>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SomeBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="00:20:00"
receiveTimeout="00:20:00" closeTimeout="00:20:00" sendTimeout="00:20:00">
<readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Even though you've set larger quotas in your binding, that binding is not being used by your service because it's never assigned to an endpoint or set as the default binding for basicHttpBinding.
Since you don't have an explicit endpoint defined in your config file, you can set your binding configuration as the default for basicHttpBinding by omitting the name attribute, like this:
<binding maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
openTimeout="00:20:00"
receiveTimeout="00:20:00"
closeTimeout="00:20:00"
sendTimeout="00:20:00">
<readerQuotas maxDepth="200"
maxStringContentLength="8388608"
maxArrayLength="16384"
maxBytesPerRead="2147483647"
maxNameTableCharCount="16384" />
</binding>
Without making it the default for all requests that use basicHttpBinding (or assigning it to an explicit endpoint), the service will create the binding with the default (and smaller) values.
For more information on default bindings (and endpoints and behaviors), see A Developer's Introduction to Windows Communication Foundation 4.
#Tim I have seen this in several spots online and it is correct, except that you are missing something else. I was getting confused since I am new to WCF and my service wraps another service so that I can perform new logic without changing the existing system. Therefore any changes I was making were only getting applied to the client I am calling into. You need to add the below <services> to the <system.serviceModel> in order for those changes to be applied to the service.
<services>
<service name="ANX.DEX001.WebService.EtPrintService">
<endpoint name="basicHttpBinding"
address="/EtPrintService.svc"
binding="basicHttpBinding"
contract="ANX.DEX001.WebService.IEtPrintService"
bindingConfiguration="APIPortBinding"/>
</service>
</services>
We have a WCF service with 4 service method & running well for last 4 years. Now client has requirement for a new service method which may return 10K to 1 million record. We have tested it with separate service and found that size of response xml is about 36MB to 200 MB and processing time it takes about 4 sec to 7-8 sec. We have made following changed in client webconfig file-
<bindings>
<basicHttpBinding>
<binding name="wsHttpBinding"
maxReceivedMessageSize="2147483647"
</binding>
</basicHttpBinding>
</bindings>
We have a fear that if we add this service method in existing service and changed maxReceivedMessageSize to max it may impact the memory consumption for whole service. And in case of simultaneous method call it may result out of memory kind of exception.
But client want to have this new service method in existing service. Please suggest what possible solution we can have. Client dont want to steam the information and sending as a zip file as for that they have to set up separate FTP location.
Thank,
#Niru
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!-- Create a custom binding for our service to enable sending large amount of data -->
<binding name="MyBasicHttpBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<!-- Enable the serializer to serialize greater number of records -->
<behavior name="SilverlightWCFLargeDataApplication.Web.SilverlightWCFServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"/>
<services>
<!-- Bind the WCF service to our custom binding -->
<service behaviorConfiguration="SilverlightWCFLargeDataApplication.Web.SilverlightWCFServiceBehavior"
name="SilverlightWCFLargeDataApplication.Web.SilverlightWCFService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
contract="SilverlightWCFLargeDataApplication.Web.SilverlightWCFService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
Read this article, maybe your answer.
https://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/
I am trying to pass large byte array to wcf service from windows phone application. I have tried all possible way's to pass large byte array but I couldn't pass it.
Here is my web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!--<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:10:00" closeTimeout="00:10:00">
<security mode="None" />
</binding>-->
<binding closeTimeout="01:30:00"
openTimeout="01:30:00" receiveTimeout="01:30:00" sendTimeout="01:30:00" transferMode="Streamed"
maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="4294967295">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
I have used the max received message size i.e. 2147483646. Now I will show my
ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx.xx.x.xxx/WebService/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="MyService.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
I am passing following parameter to my wcf service method
Service1.svc.cs
public string GetDataUsingDataContract(byte[] fileByte,string fileName,string folderName)
{
}
I have searched a lot and I found one similar example Maximum array length quota
But I heard that windows phone 8 doesn't support netTcpBinding. I have read that we can pass 2GB file to wcf service. How can I pass max byte array? I am stuck with this problem. Can someone please help me to solve this?
This is quite a common exception - have a look at the following posts on msdn social:
http://social.msdn.microsoft.com/Forums/wpapps/en-US/4fe7c526-510d-46ab-acac-9719e696f7db/an-exception-of-type-systemservicemodelcommunicationexception-occurred-in
http://social.msdn.microsoft.com/Forums/wpapps/en-US/61f1060f-846e-4e7d-b8ff-c2956e0a8677/visual-studio-2012-windows-phone-8-wcf-systemservicemodelcommunicationexception
Both seem to point to a problem with the windows 8 phone emulator. Instructions on how to work around this here:
http://countofmontecito.com/2012/11/13/wcf-and-windows-phone-8/
Full documentation here:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx
I've got a WCF Web MEthod that takes in an XElement object as a parameter. For one of my XML files (sized at 600KB or so) this works just fine, however, for this bigger XML file (about 5MB) I get a CommunicationException right away.
I've already increased the message sizes for my binding. Below is the ServiceModel section of my web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="BIMIntegrationWS.metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="BIMIntegrationWS.IntegrationService.customBinding0"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<binaryMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="BIMIntegrationWS.metadataBehavior">
<endpoint address="" binding="customBinding" bindingConfiguration="BIMIntegrationWS.IntegrationService.customBinding0"
contract="BIMIntegrationWS.IBIMIntegrationService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
On the client, my ClientConfig looks like this:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IBIMIntegrationService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:1895/IntegrationService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_IBIMIntegrationService"
contract="BIMIntegrationService.IBIMIntegrationService" name="customBindingEndpoint" />
</client>
</system.serviceModel>
Thanks in advance!
try to add following snippet into your web.config for the service application:
<system.web>
<httpRuntime maxRequestLength="16384" /> <!-- 16MB -->
</system.web>
When you host the service in web server you also have to tweak allowed request size for the web server.
Best regards,
Ladislav
Maybe your XElement has too many nodes/child elements, and you need to set the maxItemsInObjectGraph attribute under dataContractSerializer to something larger?
You probably need to change the values of the attributes of the <readerQuotas /> sub element of <binaryMessageEncoding />.
For more information, see:
http://msdn.microsoft.com/en-us/library/ms731325.aspx
http://forums.silverlight.net/forums/p/88704/205040.aspx
Update:
Can you try to increase the maxAllowedContentLength as described here:
http://social.msdn.microsoft.com/Forums/en/wcf/thread/e6e21132-ad3f-4135-8ab9-77923b099907
Do you know how to turn off VS host and to just deploy to IIS and give it a ping. Normal IIS 7 on your dev box will do just fine. You can still attach debugger etc, just won't have instantaneous F5 gratification but since your ocode is not dying on startup you don't need to see if from the fist line anyway :-)
If you would need to attach very early you could could make a mimimal method that doesn't tounch anything at all and just returns int constnat - just to bring up app pool so you can attach.
I have a WCF service hosted in IIS7 (the service and client configuration is at the end of this post). I have run across an odd scenario that I was hoping someone might have some ideas about how to attack it and find a solution.
The service only exposes one contract, 'ProcessMessage'. I can send/receive synchronous messages from the service using that contract just fine with expected performance, but one particular call to that contract returns more than 65KB of data; about 1 MB. Upon originally calling it, I received the expected max receive size exceeded error. So I increased the maxReceivedMessageSize, and now this particular call takes 40 minutes to return to the client. This is well beyond any of the timeout settings, and well beyond what I would expect it to take. The server side processing time is only 2 seconds. It appears to be held up on the client side.
I've also tried bumping up several of the other quotas in the file to no avail.
Any thoughts would be greatly appreciated. Thanks.
Service Config:
<system.serviceModel>
<services>
<service behaviorConfiguration="Lrs.Esf.Facade.Startup.FacadeBehavior"
name="Lrs.Esf.Facade.Startup.FacadeService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="default" contract="Lrs.Esf.Facade.Startup.IFacadeService">
<identity>
<servicePrincipalName value="lrsdomain/PensionDev" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="default">
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Lrs.Esf.Facade.Startup.FacadeBehavior">
<!-- 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="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Client Config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IFacadeService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:1:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://esf2.facade.testpe.pg.local/FacadeWcf/FacadeService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFacadeService"
contract="FacadeServiceReference.IFacadeService" name="WSHttpBinding_IFacadeService">
<identity>
<servicePrincipalName value="lrsdomain/PensionDev" />
</identity>
</endpoint>
</client>
You didn't increase the size of the various parameters on the server side, it seems - you should definitely try that! Use the binding configuration from your client config file on the server side as well - the service might well be choking since it's still defaulting to 64K message size.
Also, the receiveTimeout in your client binding is a bit funny - it's missing a zero digit:
<binding name="WSHttpBinding_IFacadeService"
receiveTimeout="00:1:00"
You should use receiveTimeout="00:01:00"
Marc
I have figured out the basic cause of the issue and a work-around, however additional insight would be great.
The DataSet was getting serialized in XML format by WCF. I forced the DataSet to serialize as a byte[] and the time reduced to 4 seconds. One guess is that escaping all of the characters in 4MB of XML so that the HTTP communication was valid is what caused the problem.