问题
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)
回答1:
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;
回答2:
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>
回答3:
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.
来源:https://stackoverflow.com/questions/24617146/asmx-web-service-reference-how-to-set-equivalent-to-maxreceivedmessagesize