0

I am trying to built a WCF Service that can send only some Kb's of data.

In my Service there is a method which returning the 11500 Array object to client but I want to return only 500 Array or only 500KB data at a time.

I tried to use maxStringContentLength, maxArrayLength, maxBytesPerRead, maxNameTableCharCount but no change while returning the data, It's the same 11500 Array returning.

My WCF Web.config is like this

<bindings>          
        <wsHttpBinding>
            <binding name="TestBinding" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" receiveTimeout="00:25:00">
                <!--<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />-->
                <readerQuotas   maxStringContentLength="500" maxArrayLength="500" maxBytesPerRead="500" maxNameTableCharCount="500" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>

Now I have two Quetions

1- How to limit the size of data

2- How to check the size of data on client side. How many Kb I'll receive.

I think I'll clear my questions, Please Help

EDIT 2:

    <behaviors>
        <endpointBehaviors>
             <behavior name="endpointBehavior">
                <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Xml" faultExceptionEnabled="true" />
            </behavior>
        </endpointBehaviors>

        <serviceBehaviors>
            <behavior name="STaCS">                 
                <serviceMetadata httpGetEnabled="True" />

                <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
ankit Gupta
  • 313
  • 1
  • 5
  • 19
  • Please post the compelete `` section for **both** your client and service. The quota settings on one do not affect the quota settings on the other. – Tim May 21 '14 at 07:08
  • @Tim : We don't know about the client config quota settings, we have to restrict on the server config settings. – ankit Gupta May 21 '14 at 07:12
  • Ok. Then reader quotas are your best bet. Do you have an endpoint defined in your service config file? – Tim May 21 '14 at 07:15
  • @TIm: Yes there is an endpoint in my service. – ankit Gupta May 21 '14 at 07:19
  • On further research, it looks like the quotas only apply to *received* messages, not outgoing. If you want to limit the size of the outgoing message, you may have to do it manually through a WCF Extension Point or a MessageContract. – Tim May 21 '14 at 07:31
  • @Tim: Yes u r right, quotas only apply to received messages. But How to apply WCF Extension Point. – ankit Gupta May 21 '14 at 07:33
  • Take a look at Carlos Figueira's blog - he did a series on [WCF Extensibility](http://blogs.msdn.com/b/carlosfigueira/archive/2011/03/14/wcf-extensibility.aspx) a while back that covers the various options. – Tim May 21 '14 at 07:38

0 Answers0