none
Send larger data back to WCF Service RRS feed

  • Question

  • I have a small WCF service, self hosted in a console app.
    In a previous post a solution was given for my application to receive large byte arrays From the service.
    Now I am encountering a problem with sending data back TO the service.
    If my app sends back a small byte array (say about 18K) no problem.
    If my app sends back a larger byte array (say about 188K) I get: The remote server returned an unexpected response: (400) Bad Request.
    The data apparently gets out of my application, but the service rejects it before the data even gets to the actual function.

    I am guessing I need entries in the service's app.config to allow it to Receive larger data, but I don't know what.

    What do I need?

    Thanks,


    Jon Jacobs
    In transmission, subatomic particles managed by professionals.
    No innocent electrons were harmed.

    Thursday, February 26, 2015 8:04 PM

Answers

  • Hi Jon Q Jacobs,

    In order to let the WCF Service to transfer large data, the other way is to set the some properties like maxReceivedMessageSize in both service and client side as following:

    <binding closeTimeout="00:10:00" openTimeout="00:10:00" 
         receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
         maxBufferSize="2000000" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000" 
         messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed" 
         useDefaultWebProxy="true">  
         <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" 
          maxBytesPerRead="2000000" maxNameTableCharCount="2000000" /> 

    For more information, please try to refer to this article:
    http://blogs.msdn.com/b/ryberry/archive/2010/04/20/transferring-large-blogs-of-data-with-wcf.aspx .

    Best Regards,
    Amy Peng





    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Jon Q Jacobs Friday, February 27, 2015 2:45 PM
    Friday, February 27, 2015 9:40 AM
    Moderator

All replies

  • What do I need?

    You need to use Custom Binding on the service side to override the default settings.

    http://www.codeproject.com/Tips/243357/WCF-Custom-Binding

    Thursday, February 26, 2015 9:26 PM
  • Hi Jon Q Jacobs,

    In order to let the WCF Service to transfer large data, the other way is to set the some properties like maxReceivedMessageSize in both service and client side as following:

    <binding closeTimeout="00:10:00" openTimeout="00:10:00" 
         receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
         maxBufferSize="2000000" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000" 
         messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed" 
         useDefaultWebProxy="true">  
         <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" 
          maxBytesPerRead="2000000" maxNameTableCharCount="2000000" /> 

    For more information, please try to refer to this article:
    http://blogs.msdn.com/b/ryberry/archive/2010/04/20/transferring-large-blogs-of-data-with-wcf.aspx .

    Best Regards,
    Amy Peng





    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Jon Q Jacobs Friday, February 27, 2015 2:45 PM
    Friday, February 27, 2015 9:40 AM
    Moderator