ASMX web service reference how to set equivalent to MaxReceivedMessageSize
Asked Answered
G

3

7

Web Service is an ASMX web service (NOT WCF)

I am receiving an error

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 using a proxy that Visual Studio generates for you when you add a "Web Reference" (please note that I am NOT adding "Service Reference", instead I am using Web Reference)... this creates a proxy that inherits from SoapHttpClientProtocol

Can anyone help me figure out how to set the equivalent to MaxReceivedMessageSize for this method? (I am asking for the equivalent of doing HttpBinding.MaxReceivedMessageSize = Int32.MaxValue if I were using WCF)

Ginkgo answered 7/7, 2014 at 18:19 Comment(1)
Could u post the config file?Flowage
F
5

This message is WCF specific. I suspect then you are calling your ASMX service through a WCF client proxy (client class inherits from the ClientBase). On the other hand, a typical ASMX client proxy inherits from SoapHttpClientProtocol.

The trick is, if you just "Add Service Reference" from within the Visual Studio, the WCF-like proxy is created by default. In order to create an old-type proxy, you should click "Advanced" on the proxy creator dialog and then "Add web reference" on the advanced properties dialog or invoke the wsdl.exe tool from the command line.

The proxy created in an "old" doesn't have any message quotas.

Nevertheless, using the legacy ASMX technology, both for the server and the client, is not recommended.

Fra answered 7/7, 2014 at 18:50 Comment(3)
Thanks for the response Wiktor... yes i am using "old" (Add Service Reference > Advanced > Add Web Reference). this creates a proxy that inherits from SoapHttpClientProtocolGinkgo
Is there any documentation that suggests there is no message quotas for this "old" way?Ginkgo
I've been using it for years and there was no such limitation. Is the exception thrown from the client proxy or from the server then?Fra
H
4

The MaxReceivedMessageSize change can be done in the App.config file or in the source code before calling the service's method.

 BasicHttpBinding httpBinding = youAddWebServiceName.ChannelFactory.Endpoint.Binding as BasicHttpBinding;
 httpBinding.MaxReceivedMessageSize = int.MaxValue;
Hundred answered 7/7, 2014 at 18:53 Comment(1)
From my understanding, MaxReceivedMessageSize only applies to using WCF as the client, so this would not help in this case because OP specifically says they are using a web referenceTidal
I
4

maybe it help someone. I get same error message in ASMX Web service but that's not from server! it was from client and i just add this to client config:

<basicHttpBinding>
<binding name="BindingName" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" maxBufferSize="20000000" />
</basicHttpBinding>
Inconveniency answered 28/2, 2016 at 12:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.