views:

92

answers:

4

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!

+1  A: 

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

larsw
No luck with setting up the <readerQuotas> property attributes manually. :\I'm updating the web.config in the question with those included.
Overhed
Ok, you can try to tweak the values of the <dataContractSerializer /> element too: http://msdn.microsoft.com/en-us/library/bb924506.aspx
larsw
Any hints how I would go about tweaking the values for the XElement type (or any other already Serializable type for that matter) ?
Overhed
The maxAllowedContentLength property did not do the trick. Still getting an exception with the big file.
Overhed
A: 

Maybe your XElement has too many nodes/child elements, and you need to set the maxItemsInObjectGraph attribute under dataContractSerializer to something larger?

insipid
A: 

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.

ZXX
+1  A: 

Hello,

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

Ladislav Mrnka
+1Not enough debugging info in the original question, but I think this is probably what you're running up against as the default max incoming request is limited to 4096 KB in IIS. Since you're trying to push 5MB of XML up to the server -- boom!Has the original poster tried self-hosting the app in a Windows service, instead of under IIS? If you're running this application in an Intranet environment, I would recommend self-hosing with net.tcp bindings for performance since you're pushing around a lot of data.
Ethan J. Brown
This seems to have done the trick. Many thanks Laidslav! The bounty expired, so I had to re-add it. I'll award it as soon as I can (23 hours). Thanks again!
Overhed