Click here to Skip to main content
15,885,044 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i am making a web service(Wcf) for my university management project.i am having some difficulties when i receive large amount of data from database it gives me following exception

Exception: 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

i am aware of this exception i have modified my web.config so that i can receive large amount of data here is my web.config:


XML
<system.serviceModel>
                    <diagnostics>
                      <messageLogging logEntireMessage="true" logMalformedMessages="true"
                        logMessagesAtTransportLevel="true" />
                      <endToEndTracing activityTracing="true" />
                    </diagnostics>
                    <bindings>
                      <wsHttpBinding>
                        <binding name="secureWsHttpBinding" maxBufferPoolSize="2147483647"
                          maxReceivedMessageSize="524288000" messageEncoding="Mtom">
                          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                          <security mode="Transport">
                            <transport clientCredentialType="None" />
                            <message algorithmSuite="TripleDes" establishSecurityContext="false" />
                          </security>
                        </binding>
                      </wsHttpBinding>
                    </bindings>
                    <protocolMapping>
                      <remove scheme="http" />
                      <add scheme="https" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding"/>
                    </protocolMapping>

i have set maximum values in my server side web.config file
after modifying my web.config i updated my Service Reference and visual studio Generate my Client side configuration in app.config
here is my app.config file :

XML
<system.serviceModel>
            <diagnostics>
              <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
            </diagnostics>
         <bindings>
              <wsHttpBinding>
                <binding name="WSHttpBinding_IAcdmcYrAdding" messageEncoding="Mtom">
                  <security mode="Transport">
                    <transport clientCredentialType="None" />
                  </security>
                </binding>
                <binding name="WSHttpBinding_IAdd_EmployeeRecord" messageEncoding="Mtom">
                  <security mode="Transport">
                    <transport clientCredentialType="None" />
                  </security>
                </binding>
         </wsHttpBinding>
            </bindings>
         <endpoint address="https://khurram/AlahsaanDSL.svc" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_IAcdmcYrAdding" contract="DSL.IAcdmcYrAdding"
                name="WSHttpBinding_IAcdmcYrAdding" />
              <endpoint address="https://khurram/AlahsaanDSL.svc" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_IAdd_EmployeeRecord" contract="DSL.IAdd_EmployeeRecord"
                name="WSHttpBinding_IAdd_EmployeeRecord" />
         </client>
          </system.serviceModel>

Note: in my Client Configuration i have lots of bindings and endpoints i do not want to configure every end point.

**My Question:- Is there any way by which visual studio generate my app.config file like this**

XML
<binding name="WSHttpBinding_IAcdmcYrAdding" maxBufferPoolSize="2147483647"maxReceivedMessageSize="2147483647"messageEncoding="Mtom"><readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
Posted
Updated 4-Oct-14 2:27am
v2

1 solution

Client-site configuration file, as almost all other parts of a client host, are totally invisible to the Web applications/sites. The whole approach makes no sense.

If you explain your ultimate goals, you will get a chance to receive some advice for an alternative solution.

—SA
 
Share this answer
 
Comments
khurram ali lashari 2-Oct-14 13:17pm    
i have posted my client app.config file in which visual studio automatically generate binding and endpoints after adding service reference but i want that visual studio automatically add below things in binding elements
maxBufferPoolSize="2147483647"maxReceivedMessageSize="2147483647"messageEncoding="Mtom"><readerquotas maxstringcontentlength="2147483647" maxarraylength="2147483647" maxbytesperread="2147483647" maxnametablecharcount="2147483647" <="" div=""> <div id="EditDialogPlaceholder"></div> <div id="ReplyDialogPlaceholder"></div>
Sergey Alexandrovich Kryukov 4-Oct-14 7:09am    
What difference can it make?
—SA
khurram ali lashari 4-Oct-14 8:26am    
By Setting this values maxReceivedMessageSize="2147483647" i can get large amount of data

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900