Embedd_0913
Embedd_0913

Reputation: 16545

FaultException in sending big amount of data in WCF?

I have a long xml file the content of the file are below:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://example.org/person</a:Action>
    </s:Header>
    <s:Body>
        <OrderDataBDO xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/BasWare.OM.BusinessDataObjects">
            <selected i:type="x:boolean" xmlns="">false</selected>
            <isSaved i:type="x:boolean" xmlns="">false</isSaved>
            <metadata i:nil="true" xmlns=""/>
            <hasUnsavedValues i:type="x:boolean" xmlns="">false</hasUnsavedValues>
            <hasChanged i:type="x:boolean" xmlns="">false</hasChanged>
            <defaultResourceId i:type="x:string" xmlns="">BWRc.OM.BUSINESSOBJECTS.ORDERDATABDO.ORDER_DATA</defaultResourceId>
            <_x0031_ xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:ADate" xmlns="">
                <_x0031_ i:type="x:boolean">false</_x0031_>
                <_x0032_ i:type="x:boolean">false</_x0032_>
                <_x0033_ i:type="x:boolean">false</_x0033_>
                <_x0034_ i:nil="true"/>
                <_x0035_ i:type="x:boolean">true</_x0035_>
                <_x0036_ i:type="x:dateTime">1753-01-01T12:00:00</_x0036_>
                <_x0037_ i:type="x:string">d</_x0037_>
                <_x0038_ i:type="x:string">ActualDeliveryDate</_x0038_>
            </_x0031_>
            <_x0032_ xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AString" xmlns="">
                <_x0031_ i:type="x:boolean">false</_x0031_>
                <_x0032_ i:type="x:boolean">false</_x0032_>
                <_x0033_ i:type="x:boolean">false</_x0033_>
                <_x0034_ i:nil="true"/>
                <_x0035_ i:type="x:boolean">true</_x0035_>
                <_x0036_ i:type="x:string"/>
                <_x0037_ i:nil="true"/>
                <_x0038_ i:type="x:string">BuyerCode</_x0038_>
            </_x0032_>
            <_x0033_ xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AID" xmlns="">
                <_x0031_ i:type="x:boolean">false</_x0031_>
                <_x0032_ i:type="x:boolean">false</_x0032_>
                <_x0033_ i:type="x:boolean">false</_x0033_>
                <_x0034_ i:nil="true"/>
                <_x0035_ i:type="x:boolean">true</_x0035_>
                <_x0036_ i:type="x:string"/>
                <_x0037_ i:nil="true"/>
                <_x0038_ i:type="x:string">BuyerId</_x0038_>
            </_x0033_>
            <!--etc-->
            <_x0034_6 xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AMoney" xmlns="">
                <_x0031_ i:type="x:boolean">false</_x0031_>
                <_x0032_ i:type="x:boolean">false</_x0032_>
                <_x0033_ i:type="x:boolean">false</_x0033_>
                <_x0034_ i:nil="true"/>
                <_x0035_ i:type="x:boolean">true</_x0035_>
                <_x0036_ i:type="x:decimal">0</_x0036_>
                <_x0037_ i:type="x:string">N2</_x0037_>
                <_x0038_ i:type="x:string">TaxSum</_x0038_>
            </_x0034_6>
            <_x0034_7 xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AString" xmlns="">
                <_x0031_ i:type="x:boolean">false</_x0031_>
                <_x0032_ i:type="x:boolean">false</_x0032_>
                <_x0033_ i:type="x:boolean">false</_x0033_>
                <_x0034_ i:nil="true"/>
                <_x0035_ i:type="x:boolean">true</_x0035_>
                <_x0036_ i:type="x:string"/>
                <_x0037_ i:nil="true"/>
                <_x0038_ i:type="x:string">Text1</_x0038_>
            </_x0034_7>
            <_x0034_8 xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AString" xmlns="">
                <_x0031_ i:type="x:boolean">false</_x0031_>
                <_x0032_ i:type="x:boolean">false</_x0032_>
                <_x0033_ i:type="x:boolean">false</_x0033_>
            </_x0034_8>
        </OrderDataBDO>
    </s:Body>
</s:Envelope>

Upvotes: 2

Views: 1750

Answers (3)

marc_s
marc_s

Reputation: 754230

You need to set various of your settings - play around with the values, and see which work.

First, use whatever binding you're using and tweak the <readerQuotas> (maxStringContentLength, maxArrayLength, maxNameTableCharCount) - if that works, fine!

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="LargeMessages">
          <readerQuotas maxDepth="32"
            maxStringContentLength="2147483647"
            maxArrayLength="2147483647"
            maxBytesPerRead="4096"
            maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

If that doesn't solve your problem, you'll need to create your own custom binding in config, and set the limits on the message level as well - something like this:

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="ExtraLargeMessages">
          <textMessageEncoding>
            <readerQuotas maxDepth="32"
              maxStringContentLength="2147483647"
              maxArrayLength="2147483647"
              maxBytesPerRead="4096"
              maxNameTableCharCount="2147483647" />
          </textMessageEncoding> 
          <httpsTransport 
              maxBufferPoolSize="1048576"
              maxReceivedMessageSize="1048576"
              maxBufferSize="1048576"/>
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>

Hope this helps.

Marc

UPDATE:
I would tryto add this behavior to your service, and then call the method again.

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DetailedDebug" >
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="yourService" behaviorConfiguration="DetailedDebug">
        .....
      </service>
    </services>
  </system.serviceModel>

You should now get detailed exception info on your client - can you tell us what it is?? Maybe it's something totally different.......

Marc

Upvotes: 2

Giulio Vian
Giulio Vian

Reputation: 8343

Maybe it's the number of objects: try adding something like this

  <serviceBehaviors>
    <behavior name="PutTheNameOfYourBehaviorHere">
      <dataContractSerializer maxItemsInObjectGraph="10000000" />
    </behavior>
  </serviceBehaviors>

to your config file.

Upvotes: 0

JP Alioto
JP Alioto

Reputation: 45117

Change your Max Message Size (for example, depending on your binding) on the client and server as described here.

Something else may be going wrong. Can you enable tracing for WCF and use the trace log viewer to narrow down the exception?

Upvotes: 0

Related Questions