Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASMX web service reference how to set equivalent to MaxReceivedMessageSize

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)

like image 498
Gustavo Avatar asked Jul 07 '14 18:07

Gustavo


People also ask

What is the maximum value for MaxReceivedMessageSize?

MaxReceivedMessageSize = 1000000; The value of this property can also be set in the configuration file.

What is default MaxReceivedMessageSize?

You need to set the MaxReceivedMessageSize attribute in your binding configuration. By default, it is 65536.


1 Answers

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;
like image 90
bashkan Avatar answered Nov 14 '22 23:11

bashkan