Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending large XML from Silverlight to WCF

I want to send a big XML string to a WCF SVC service from Silverlight.

It looks like anything under about 50k is sent correctly but if I try to send something over that limit, my request reaches the server (BeginRequest is called) but never reaches my SVC. I get the classic "NotFound" exception.

Any idea on how to raise that limit?

If I can't raise it? What are my other options?

Here's my binding configuration

<bindings>
        <customBinding>
            <binding name="customBinding0" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
                <binaryMessageEncoding>
        <readerQuotas
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxDepth="2147483647"
            maxNameTableCharCount="2147483647"
            maxStringContentLength="2147483647" />

      </binaryMessageEncoding>
                <httpTransport/>
            </binding>
            <binding name="customBindingSecure" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
                <binaryMessageEncoding>
        <readerQuotas
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxDepth="2147483647"
            maxNameTableCharCount="2147483647"
            maxStringContentLength="2147483647" />
                </binaryMessageEncoding>
                <httpsTransport/>
            </binding>
        </customBinding>
    </bindings>

Edit: More details : If I break in the Global.asax Endrequest, I see in the Response "Bad Request 400"

Edit: More details again : I activated the Trace and I can see the following error : 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.

However, my maxReceivedMessageProperty is already set to 2147483647.

like image 902
2d1b Avatar asked May 21 '10 13:05

2d1b


2 Answers

Ok got it working!

Since I am using a customBinding, the maxReceivedMessageSize has to be set on the httpTransport element like this :

<bindings>
        <customBinding>
            <binding name="customBinding0" >
                <binaryMessageEncoding>
        <readerQuotas
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxDepth="2147483647"
            maxNameTableCharCount="2147483647"
            maxStringContentLength="2147483647" />

      </binaryMessageEncoding>
                <httpTransport maxReceivedMessageSize="4194304" />
            </binding>
            <binding name="customBindingSecure">
                <binaryMessageEncoding>
        <readerQuotas
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxDepth="2147483647"
            maxNameTableCharCount="2147483647"
            maxStringContentLength="2147483647" />
                </binaryMessageEncoding>
                <httpsTransport  maxReceivedMessageSize="4194304" />
            </binding>
        </customBinding>
    </bindings>

Thank you all for your help!

like image 158
2d1b Avatar answered Oct 13 '22 20:10

2d1b


You can also turn on WCF logging for more information about the original error. This helped me solve this problem.

Add the following to your web.config, it saves the log to C:\log\Traces.svclog

<system.diagnostics>
    <sources>
        <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true">
            <listeners>
                <add name="traceListener"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData= "c:\log\Traces.svclog" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>
like image 36
Aaron Hoffman Avatar answered Oct 13 '22 19:10

Aaron Hoffman