WCF service communication exception due to parameter size

I have a WCF Web MEthod that takes an XElement object as a parameter. For one of my XML files (600 KB or so), this works fine, however, for this larger XML file (about 5 MB) I immediately get a CommunicationException message.

I have already increased the message sizes for my binding. The following 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!

+4
source share
4 answers

try adding the following snippet to your web.config for the service application:

  <system.web> <httpRuntime maxRequestLength="16384" /> <!-- 16MB --> </system.web> 

When you host the service on a web server, you also need to configure the allowed request size for the web server.

Regards, Ladislav

+1
source

You probably need to change the attribute values ​​of the <readerQuotas /> subelement to <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 maxAllowedContentLength , as described here: http://social.msdn.microsoft.com/Forums/en/wcf/thread/e6e21132-ad3f-4135-8ab9-77923b099907

+1
source

Perhaps your XElement has too many nodes / children and you need to set the maxItemsInObjectGraph attribute under dataContractSerializer to something more?

+1
source

Do you know how to disable the VS-host and just deploy to IIS and give it a ping. The normal IIS 7 in your dev block will work just fine. You can still attach a debugger, etc., you just won’t get instant F5 satisfaction, but since your ocode doesn't die at startup, you still don’t need to see if from the first line :-)

If you need to connect very early, you could make a mimimal method that doesn't let anything go at all, and just returns int constnat - just to open the application pool so you can attach.

0
source

All Articles