Skip to main content

Microsoft Silverlight

Answered Question Setting maxReceivedMessageSize in WCF no longer works in beta 2RSS Feed

(0)

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Setting maxReceivedMessageSize in WCF no longer works in beta 2

I have found the WCF call has a ReceivedMessageSize limit now in beta2.

In beta 1, the default maxReceivedMessageSize/maxBufferSize is set to 65536. If we are passing back data which exceeding this size, we need to set maxReceivedMessageSize/maxBufferSize to a large value in the web.config, on the silverlight side we had to create a new BasicHttpBinding in code and set the maxReceivedMessageSize/maxBufferSize to a larger number. And it works.

Now in beta 2. we are suppose do any Silverlgiht side configuration change in the ServiceReferences.ClientConfig file. But it does not work. The service error out if the data passing back exceeding the default size (not the size I specified in the config file). I also tried to create a new BasicHttpBinding in code just like I did in beta 1.  That no longer work either. Now I'm not able to send any large data back to WCF call.

Is this a bug? Anybody has seen the same thing. My upload file code totally broke due to this. I can only send very small file back. If the file string length exceeding 8000 the service is error out.

 
 


 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

party42
party42

Participant

Participant

1102 points

338 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

I was hoping they would have fixed this, also see my post here: http://silverlight.net/forums/t/16554.aspx. Especially the part where Allen said:

Allen Chen – MSFT:

Hi:

The client config file does not work in current Silverlight. We have to explicitly specify the address in code. It'll take effect in Beta 2 which will be released very soon.

Regards


But now you're saying it still doesnt work?

Regards,
Nathan Brouwer

http://www.nathanbrouwer.nl

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 It's worse than before. I used to be able to do it in code in beta 1. Now none of them works. The address is reading from the clientConfig without problem. but the size set in the config or code has no effect.

 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Allen Chen – MSFT
Allen Ch...

Star

Star

13862 points

1,803 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hi:

  Try to set maxStringContentLength to a large value to see if it works (server side config):

<bindings>
      <basicHttpBinding>
        <binding name="testbinding" maxBufferSize="65536" maxReceivedMessageSize="65536">
          <readerQuotas maxStringContentLength="large_value"/>
        </binding>
      </basicHttpBinding>
    </bindings>

<service behaviorConfiguration="SilverlightApplication3Web.Service1Behavior" name="SilverlightApplication3Web.SilverlightTestService">
    <endpoint bindingConfiguration="testbinding"  ....

  For more details please check out:

http://msdn.microsoft.com/en-us/library/ms731325.aspx

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 Allen,

Thank you for your response! Finally I got a hold on someone from Microsoft. Here is my configuration setting:

Web.Config in my Web Project: 

<service behaviorConfiguration="Aprimo.Web.WCF.UploadBehavior" name="Aprimo.Web.WCF.Upload">
    <endpoint address="" binding="basicHttpBinding" bindingName="LargeBuffer" contract="Aprimo.Web.WCF.Upload" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>

<bindings>
   <basicHttpBinding>
    <binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
   </basicHttpBinding>
</bindings>

Here is my Configuration in the ServiceReferences.ClientConfig

<endpoint address="http://localhost:1432/WCF/Upload.svc" binding="basicHttpBinding"
                bindingConfiguration="LargeBuffer" contract="Aprimo.Silverlight.UploadService.Upload"
                name="LargeBuffer_Upload" />

<basicHttpBinding>
                <binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>             
</basicHttpBinding>

 
 <readerQuotas/ > Tag on ServiceReferences.ClientConfig is invalid tag. So I can not put that in. But I don't think it matters either. I have maxReceivedMessageSize/maxBufferSize set to the largest possible number for a integer.

But this just not working as expected. You can try to write a very simple WCF something like :

[OperationContract]
        public string DoWork(string value)
        {
             return value;

       }

Then try to call it passing a string value. If your string length is small, no problem,  You will hit the WCF code and everything works fine. But once the string length exceeding 8192 chars, You will get an error before you event hit the WCF code. The error message would be 404 Page not found error.

I had this problem in beta 1, see http://silverlight.net/forums/p/11574/37141.aspx#3714

But we managed to set the binding size in code to get around it.

System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                binding.MaxReceivedMessageSize = 2147483647; // int's max size
                binding.MaxBufferSize = 2147483647; // int's max size
                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../WCF/Upload.svc"));                            

 var fs = new UploadService.UploadClient(binding, address);   

...

 

But now, that code won't fix this problem either.  This problem is really a big one. I hope you can give us a solution soon.

Thanks again!

 

 


 

 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Allen Chen – MSFT
Allen Ch...

Star

Star

13862 points

1,803 Posts

Answered Question

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hi:

sladapter:

<service behaviorConfiguration="Aprimo.Web.WCF.UploadBehavior" name="Aprimo.Web.WCF.Upload">
    <endpoint address="" binding="basicHttpBinding" bindingName="LargeBuffer" contract="Aprimo.Web.WCF.Upload" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>

<bindings>
   <basicHttpBinding>
    <binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
   </basicHttpBinding>
</bindings>

  I think we should set bindingConfiguration for the endpoint (not bindingName):

<bindings>
      <basicHttpBinding>
        <binding name="testbinding" maxBufferSize="65536" maxReceivedMessageSize="65536">
          <readerQuotas maxStringContentLength="large_value"/>
        </binding>
      </basicHttpBinding>
    </bindings>

<service behaviorConfiguration="SilverlightApplication3Web.Service1Behavior" name="SilverlightApplication3Web.SilverlightTestService">
    <endpoint bindingConfiguration="testbinding"  ....

 

sladapter:
You will hit the WCF code and everything works fine. But once the string length exceeding 8192 chars, You will get an error before you event hit the WCF code.

 

  Please try again. It looks exactly the readerQuotas issue. You can see the default value of maxStringContentLength is 8192.

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 Allen,

Yes, it works when I use the set bindingConfiguration=LargeBuffer.

This must be another undocumented change. Because it was using BindingName in beta1 and it worked that way.

Thank you for take care of this issue. This is important to us.

 

 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

bartczernicki
bartczer...

Contributor

Contributor

4208 points

738 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

I can't set this line in the config:

<readerQuotas maxStringContentLength="large_value"/>

readerQuotas is underlined and it bombs out when I try to run it.  Am I missing a reference or something in the .config file. BTW yes I am setting it to a value :) (no the word large_value)

 Thanks,

Bart

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 It's in the Web.Config, not the ClientConfig. In ClientConfig, you do not need that and it's invalid tag.

By the way, he meant you specify a large value in for that field, not just use "large_value".

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

CleverCoder
CleverCoder

Member

Member

203 points

157 Posts

Re: Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

What if I'm not using WCF? A standard web service seems to have the same problem:

The error I get is: "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."

Where is this configured for a standad web service (asmx)?

bartczernicki
bartczer...

Contributor

Contributor

4208 points

738 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 I figured that out myself actually after re-reading the post above.  Still doesn't work though..so I have no idea what is happening.  Can you copy your web.config and service.config so I can see them.  I tried putting all the readQuotas and then only doing what MS specified still nothing.  I tried setting them to the int max and then 1000000 still nothing.  I am going to try to do the client proxy manually and see if that helps and re-doing the service (since I changed it an Interface, since putting the attributes into the logic is a complete mess). 


So, my smaller calls work fine..so I know its workings..just when I go over 10,000 rows its gives a 404.  Limiting that to say 5,000 rows works fine..so I know this is the problem.

CleverCoder
CleverCoder

Member

Member

203 points

157 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 I guess the only real solution then is to chunk the requests until MS has a better fix...  or someone comes up with a better solution.
*rats*

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Web.Config in your Web Project: 

<system.serviceModel>
  <bindings>
   <basicHttpBinding>
    <binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>

   </basicHttpBinding>
  </bindings>
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
   <services>
   <service behaviorConfiguration="MyNameSpace.UploadBehavior"
    name="Aprimo.Web.WCF.Upload">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="LargeBuffer"  contract="MyNameSpace.Upload" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
  </services>
        <behaviors>
   <serviceBehaviors>   
    <behavior name="MyNameSpace.UploadBehavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
</system.serviceModel>

ServiceReferece.ClientConfig under Silverlight Project: 

 <configuration>
    <system.serviceModel>              
        <bindings>                        
            <basicHttpBinding>                            
                <binding name="LargeBuffer_Upload" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>        
            <endpoint address="http://localhost:1475/WCF/Upload.svc" binding="basicHttpBinding"
                bindingConfiguration="LargeBuffer_Upload" contract="Aprimo.Silverlight.UploadService.Upload"
                name="LargeBuffer_Upload" />
        </client>
    </system.serviceModel>
</configuration>

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

daxsorbito
daxsorbito

Member

Member

12 points

6 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hi, can you send me a sample project implementing this? I'm so lost on this. Thanks in advance. My email add is daxsorbito@gmail.com.

bartczernicki
bartczer...

Contributor

Contributor

4208 points

738 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

I followed your instructions and still nothing (looking back at it, I had the same thing). 

What I am returning is a serialized List of my custom type/class.  So, when I leave the message buffer at 64k it definitely gives me an error saying the message size is too small.  So, increasing it definitely works and I can receive more data, except I seem to reach  a max (even though the message buffer is at 2 gig) around 10,000 rows (this obviously depends on the fact of the data inside each row).  So, something else is going on here.  I am going to post a project with dummy data and hopefully this can be figured out, because it is really annoying that this is happening (or this might be a limitation of WCF that I do not know about).

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

bartczernicki:

I followed your instructions and still nothing (looking back at it, I had the same thing). 

What I am returning is a serialized List of my custom type/class.  So, when I leave the message buffer at 64k it definitely gives me an error saying the message size is too small.  So, increasing it definitely works and I can receive more data, except I seem to reach  a max (even though the message buffer is at 2 gig) around 10,000 rows (this obviously depends on the fact of the data inside each row).  So, something else is going on here.  I am going to post a project with dummy data and hopefully this can be figured out, because it is really annoying that this is happening (or this might be a limitation of WCF that I do not know about).

 

Hi, I have seen the same thing. When I try to upload a file if the file size is exceeding 4MB I hit the limit again although I set all the sizes for the service to the largest possible integer number (~2GB).  Then I found out the limit is the httpRuntime.maxRequestLength which default to 4096KB in machine.config file. So I increase that setting by set <httpRuntime maxRequestLength="8192" /> in my web.config. That increase the limit to 8MB.

This is size for Http Request, I'm not sure it will affect the return data or not. And I do not have that large data to return to test it. If you want to try, you just add the following line in your web.config under <system.web> node.

 

<system.web>

    ... 

   <httpRuntime maxRequestLength="8192" />  // You can change this number to see it has any impact of your return size.
</system.web> 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

bartczernicki
bartczer...

Contributor

Contributor

4208 points

738 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Thanks for the reply.  That didn't work...BUT I solved my problem.  It was the DataContractSerializer element and you need to set the maxItemsInObjectGraph to a higher number, looks like the default number for serialized items is low.  This really should throw a serialization exception in WCF.

I guess I'll do a little write up about this experience on my blog.  It was a fun 2 days trying to get this to work and at a good time (right before the weekend) :)

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

OK. Now we know there are so many settings can affect the size of data that can pass back and fourth between WCF and WCF client. It's good learning for everybody. 

By the way, where do you set maxItemsInObjectGraph ?

 

 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

daxsorbito:

Hi, can you send me a sample project implementing this? I'm so lost on this. Thanks in advance. My email add is daxsorbito@gmail.com.

 

What sample project do you need (File Uploading or just WCF) ? What kind of problem are you having?


 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

bartczernicki
bartczer...

Contributor

Contributor

4208 points

738 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 

In the binding, probably went too excessive with the max, but it helps.  This is screaming for a writeup, because many people will have the same exact question.  I'll post it this weekend (I am launching my newer site then).

<behavior name="SilverlightSelfServiceQueryWeb.Service1Behavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="false" />

<dataContractSerializer maxItemsInObjectGraph="6553600"/>

</behavior>

 

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

OK, It's in the Service Behavior section.

If you write a Blog, please give people instruction on how to use WCF Configuration Editor to edit those settings. It is very confusing to set those settings in the configuration file by hand. It so easy to mess up the whole configuration if you just mistype something and you don't even know how to fix them.


 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

daxsorbito
daxsorbito

Member

Member

12 points

6 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hi, actually we are just testing the capabilities of these technologies. One factor that we want to capture is the capability of silverlight+WCF retrieving large amount of data. But it seems I always get a 404 upon calling the WCF. I'm just worried I might miss something that causing the 404. That's why I was hoping to see a sample application so that I could trace what I did wrong.

 Thanks.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 daxsorbito,

 I just sent you the sample project and you can check it out.

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

leaf_fan
leaf_fan

Member

Member

70 points

33 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hey guys, just wanted to say thanks - this thread saved me as well.

 

Specifically using this setting resolved my 404 error:

<dataContractSerializer maxItemsInObjectGraph="6553600"/>

I wonder if this has more to do with the vs2008 sp1 beta than Silverlight beta 2, it would seem odd that Silverlight would somehow require this.  I agree with sladapter, more undocumented gems!

Dean.Lu
Dean.Lu

Member

Member

14 points

8 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

sladapter:

Web.Config in my Web Project: 

<service behaviorConfiguration="Aprimo.Web.WCF.UploadBehavior" name="Aprimo.Web.WCF.Upload">
    <endpoint address="" binding="basicHttpBinding" bindingName="LargeBuffer" contract="Aprimo.Web.WCF.Upload" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>

<bindings>
   <basicHttpBinding>
    <binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
   </basicHttpBinding>
</bindings>

Pretty nice! It's very useful to me!

cyberhuey
cyberhuey

Member

Member

18 points

13 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

sladapter:

System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                binding.MaxReceivedMessageSize = 2147483647; // int's max size
                binding.MaxBufferSize = 2147483647; // int's max size
                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../WCF/Upload.svc"));                            

 

This was the part I was missing. I had the web.config and the client but  did not have the local object defined with these settiongs. Thanks eveyone for being so dilligent with this.

djarvis8
djarvis8

Member

Member

4 points

2 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hi.

 I have set every setting mentioned in this post, triple-checked everything on both sides (client and server), and I still get a 404 error.  Could there possibly be any other setting that I haven't come across yet?

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

djarvis8:

Hi.

 I have set every setting mentioned in this post, triple-checked everything on both sides (client and server), and I still get a 404 error.  Could there possibly be any other setting that I haven't come across yet?

 

Since this is your first post. We don't know what your problem is. You could get 404 error for many reasons. Not a single solution can fix them all. The most likely reasons are the following:

1) Cross domain issue. Depending how you set up your Service. Is your Service running from the same Web Site(project) as your Silverlight page? Or the service is running in a separate Service Web project. What is URL for the endpoint of your service in the ClientConfig? If using DevServer, the url contains port number. Is your service still running under that port number?

If running from IIS, do you have clientaccesspolicy.xml in place (need to be in the wwwroot folder if using IIS)?

Even have clientaccesspolicy.xml or crossdomain.xml file in the right place, the file has to be compatible with SL2 beta2.

2) Data size issue, mainly discussed in this thread. You only get the 404 error when data exceeding certain size. Need configuration change for large data to be passed between Silverlight and Service.

3) Data Serialization issue. The Data type passed to Silverlight has to be the Type supported by Silverlight. If suspect this problem, try simple Service code (like HelloWorld) first. First make sure you can connect before putting in real service code.

So please be more specific about your problem. 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

rajat.barik
rajat.barik

Member

Member

14 points

11 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

None of the above ideas are working fine...

Not even after incressing the size.

If you have any code project please upload it and sent me the reference. If possible.

party42
party42

Participant

Participant

1102 points

338 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 try creating a console application and add a reference to the webservice in that one. Also, try calling the method from that console application. This will give you a more detailed look in the error message (if its actually the service causing the error).

Regards,
Nathan Brouwer

http://www.nathanbrouwer.nl

rabindra_dalai
rabindra...

Member

Member

2 points

1 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

if my collection contains 5 objects working fine . but more than 5 objects are there in my collection Serviceclient throwing following error

The remote server returned an unexpected response: (400) Bad Request.

i have increased the max message size to  2147483647 and i added the <dataContractSerializer maxItemsInObjectGraph="6553600"/>in server config file.

Still i am facing the same issue..

The remote server returned an unexpected response: (400) Bad Request.

 

 

Is there any thing i missed out.?

 <wsHttpBinding>
        <!--phtoRequest-->
        <binding name="WSHttpBinding_IShotRequestService" closeTimeout="00:010:00"
                    openTimeout="00:010:00" receiveTimeout="00:10:00" sendTimeout="00:010:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
              maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>

in server config

<dataContractSerializer maxItemsInObjectGraph="6553600"/>

riaz.afridi
riaz.afridi

Member

Member

28 points

19 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hi,

Can u please send me the same sample project as well. I am having exactly the same problem. I have applied every thing the same as mentioned here, but I am still getting the error [maximum message size quota for incoming messages (65536) has been exceeded] 

This will a huge favour to me.

Thanks

Riaz Afridi 

 

riaz.afridi
riaz.afridi

Member

Member

28 points

19 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Hi,

Can u please send me the same sample project as well at riaz.afridi@gmail.com. I am having exactly the same problem. I have applied every thing the same as mentioned here, but I am still getting the error [maximum message size quota for incoming messages (65536) has been exceeded] 

This will a huge favour to me.

Thanks

Riaz Afridi 

 

SteveReconG
SteveReconG

Member

Member

18 points

26 Posts

Re: Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 I made all the config changes as well and as with above, it wasn't until I set it in code did it work...

 System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                binding.MaxReceivedMessageSize = 2147483647; // int's max size
                binding.MaxBufferSize = 2147483647; // int's max size
                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../WCF/Upload.svc"));  

Alex A-L
Alex A-L

Member

Member

8 points

4 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 I did all the changes indicated on this page, even the ones in the code...

 It didn't change anything, I'm still getting the message that I busted max value for maxReceivedMessageSize

 Did I do something wrong?

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Alex A-L,

Please be more specific about your problem. Are you trying to do fileupload?

Read the following thread that might help you:

http://silverlight.net/forums/p/21513/75649.aspx#75649

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Alex A-L
Alex A-L

Member

Member

8 points

4 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 I'm trying to do linq in a wcf Services so i'm accessing my DB and Retreiving Dll's in Image format, so i bust the basic quota

 My web.config looks like this: 

 <bindings>
     
      <basicHttpBinding>
        <binding name="BasicHttpBinding_Query"
         closeTimeout="00:05:00"
         openTimeout="00:05:00"
         receiveTimeout="00:05:00"
         sendTimeout="00:05:00"
         maxBufferSize="2147483647"
         maxBufferPoolSize="524288"
         maxReceivedMessageSize="2147483647">
          <readerQuotas
           maxDepth="2147483647"
           maxStringContentLength="2147483647"
           maxArrayLength="2147483647"
           maxBytesPerRead="2147483647"
           maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding></bindings>

 <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <services>
            <service behaviorConfiguration="EasyDocumentsOnlineAppWeb.QueryBehavior" name="EasyDocumentsOnlineAppWeb.Query">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Query"  contract="EasyDocumentsOnlineAppWeb.Query"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
      </services>

 and this is the clientconfig :

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_Query" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:49459/Query.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_Query" contract="ServiceReference1.Query"
                name="BasicHttpBinding_Query" />
        </client>
    </system.serviceModel>
</configuration>

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

OK, you hit the returning data limit,  You need to set maxItemsInObjectGraph in the DataContractSerializer tag in you Web.Config Service behavior section:

Find the Behavior tag for your Service in web.config:

<behavior name="YourService.Service1Behavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="false" />

<dataContractSerializer maxItemsInObjectGraph="6553600"/>    // Add this line

</behavior>

 

By the way, any particular reason that you want store dlls in a database and dynamically load them over to Silverlight?  Not that you cannot do it, just not the most efficient way.

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Alex A-L
Alex A-L

Member

Member

8 points

4 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 I already did and it doesn't change anything

 And for the dll's it's what my supervisor asked!

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 What's the limit you are hitting? What is the largest data you can return without problem? 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Alex A-L
Alex A-L

Member

Member

8 points

4 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 my partner got it while I was out on lunch!

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

 Got what? What was the problem?

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

GTMistral
GTMistral

Member

Member

4 points

3 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

The problem was (I am the so called partner of that guy) we were exceeding the buffer's limit as said multiple times before in this thread. We tried many things in web.config and ClientConfig but nothing could make any difference. The limit was 65536, though we had 2147483647 everywhere and couldn't get that fixed. Maybe it's a bug. So, I went in my client C# code and did this...

// This code worked.

BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxBufferSize = int.MaxValue - 1; binding.MaxReceivedMessageSize = int.MaxValue - 1; QueryClient proxy = new QueryClient(binding, new EndpointAddress(http://localhost:49459/Query.svc));

... instead of just going for the QueryClient object.

 

// This code doesn't work.

QueryClient proxy = new QueryClient(new BasicHttpBinding(), new EndpointAddress(http://localhost:49459/Query.svc));

 ... sorry for misformating my message, I'm still at figuring out how this forum works. :/ For some reason, each line return in plain text result in now line return at all when posting or with regular form (or enhanced), it's giving me double line return each time.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Yes, you can create the binding in the code, and pass it to the Service constructor.  But when you do this, you need to set the MaxBufferSize in code as well.  Because when you create binding in code and pass it to the service constructor, you by-pass the cleint config reading. 

I'm pretty sure setting binding in code or in client config file both works. Your problem was that you created binding in code, but set the MaxBufferSize in the config file.  That certainly won't work.

The ServiceClient constructor has 5 signatures:

ServiceClient()  // Read everything (address, binding) from ClientConfig

ServiceClient(string endPointConfigruationName); //  Read everything (address, binding) from ClientConfig

ServiceClient(string endPointConfigruationName,  string remoteAddress);  // by-pass the address reading from client config, but read binding info from the file

ServiceClient(string endPointConfigruationName,  EndPointAddress remoteAddress);  // by-pass the address reading from client config, but read binding info from client config

ServiceClient(Binding binding,   EndPointAddress remoteAddress);  // by-pass client config reading totally

Now you should understand which one to use and how to use them.

By the way, do not put hardcoded URL in the code. The URL http://localhost:49459/Query.svc you put in your code only works in your current develop enviroment under Dev Server. That port number (49459) could change even during development (when the DevServer restart, sometime it starts with another port number unless you set a fixed port number in your project property page). It will definitely fail after you deploy your project to IIS.  The best way to avoid this is to build the URL dynamcally:

Uri url = new Uri(Application.Current.Host.Source, "../Query.svc");  

EndPointAddress remoteAddress = new EndPointAddress(url);

QueryClient proxy = new QueryClient( endPointConfigruationNamet, remoteAddress);

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

GTMistral
GTMistral

Member

Member

4 points

3 Posts

Re: Setting maxReceivedMessageSize in WCF no longer works in beta 2

Thx for the great tip sladapter! We're both new in business level development and we have a lot to learn.

 We weren't thinking that we were actually overriding the configuration by setting our binding manually. Works as well with default constructor.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities