views:

116

answers:

2

I have no trouble retrieving a large amount of data, but sending it back to the service displays this error. I've tried adding the element to both the web.config and servicereferences.clientconfig and it's not recognized in either. At one point I got a message about adding readerQuotas to bindingElementExtensions, but I can't find anything useful on how to do this. I found posts saying I had to modify the devenv.exe.config and such, but doing that hosed VS. I've been trying to solve this for two days so any help would be appreciated.

edit: here's the binding section of the web.config:

<bindings>
  <customBinding>
    <binding name="QaRiM.Web.Service1.customBinding0">
      <binaryMessageEncoding />
      <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>
  </customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true" />
<services>
  <service name="QaRiM.Web.Service1">
    <endpoint address="" binding="customBinding" bindingConfiguration="QaRiM.Web.Service1.customBinding0"
      contract="QaRiM.Web.Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

and the servicereferences.clientconfig:

<configuration>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="CustomBinding_Service1">
                    <binaryMessageEncoding />
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:36533/Service1.svc" binding="customBinding"
                bindingConfiguration="CustomBinding_Service1" contract="ServiceReference1.Service1"
                name="CustomBinding_Service1" />
        </client>
    </system.serviceModel>
</configuration>

Both were generated by VS.

+1  A: 

You are simply missing the configuration for the maximum string content length.

Add this to your binding attributes (client and server)

<readerQuotas maxStringContentLength="2147483647" />

Sorry, I didn't realize that this child element is located under the encoding being used when using a custom binding, it appears to bebinaryMessageEncoding in your example. If not, try the other encodings with the setting.

<bindings>
    <customBinding>
        <binding name="QaRiM.Web.Service1.customBinding0">                  
            <binaryMessageEncoding>
                <readerQuotas maxStringContentLength="2147483647"/>
            </binaryMessageEncoding>
        </binding>
    </customBinding>
</bindings>
Jab
That's the problem, it's not a valid binding attribute.
Jim Perry
@Jim Perry please take a look at the update to my answer.
Jab
That doesn't work either. It's not valid in the services config and with it in the web.config every call to the services crashes the app.
Jim Perry
Did you turn on tracing to see why it's crashing? This is the correct setting, but you may need to figure out which encoding to apply it to.
Jab
Look into WCF tracing for more detailed error messages. If it's failing, it will show it. You shouldn't have to resort to fiddler to see the exception.
Jab
WCF tracing doesn't seem to give me any more detail than Fiddler. There's still the issue with sending XML data that's more than 8K to the service.
Jim Perry
A: 

edit: This saved an incomplete draft, sorry

  1. Synchronizing the service/client definitions is what you've done but it's definitely imperative that they match.
  2. Are you sure you need custom binding? Have you tried using ws(Dual)HttpBinding as a base?
  3. This post may be of interest: http://stackoverflow.com/questions/2164065/silverlight-3-wcf-service-configuration-getting-maxreceivedmessagesize-error, specifically the httpRuntime maxRequestLength="2147483647" setting.
  4. You may need to set maxBufferPoolSize and maxItemsInObjectGraph. The config in the linked SO post pretty much maxed everything out.
  5. I don't know if you use the ChannelFactory client proxy method or the service reference method but you may wish to go the former route. In debug sessions I was finding certain values from the config weren't being applied as I had thought but my short term memory on the subject is rather lost now.
  6. Related to #5 somewhat, you can run into WCF Test Client issues where the test client is using default bindings that you're not prepared for.
  7. Another post that may be of interest: http://www.haveyougotwoods.com/archive/2008/04/14/wcf-message-streaming.aspx

Streaming is likely your best bet on the client side to keep from the blocking nature of buffered transferMode. I don't know the specifics of how big the data will be consistently but your service will behave a little nicer on the client end if you went that route. A good primer on configuring just the client side for streaming can be found here: http://systemmetaphor.blogspot.com/2009/05/using-wcf-to-transfer-large-data-files.html.

Hopefully some combination of the above helps

w0rd-driven
Using WCF tracing, nothing useful is displayed. Fiddler was the only reason I figured out the max string content length issue was the problem. I'm just guessing, but the thing about bindingElementExtensions seems relevant, I just can't find any info on how to add it correctly.
Jim Perry
The bits that stood out in the documents I were finding on Google were <httpRuntime maxRequestLength="2147483647 /> and maxItemsInObjectGraph. The former because ASP.NET by default has a cap on request sizes and the latter was just really impressed as "the only thing I changed that seemed to do anything" kind of behavior.
w0rd-driven
It does seem like you are in the right direction though but you should be able to trace why the app is failing in ASP.NET. I've only used WCF in the self hosting route and I want to say that gave me a little more freedom to determine weird errors such as this without something like ASP.NET getting in the way (not that it does at all in most instances)
w0rd-driven
I know why the app is failing, it's why I can't fix it using the solutions I've found that's the problem. :(
Jim Perry