Why the MaxReceivedMessageSize property no worked after I set it?

  • Thread starter Thread starter mywatermelon
  • Start date Start date
M

mywatermelon

Guest
I connected a webservice and used it like this:

public ServiceReference1.sycpxx[] GetProduct() {
ServiceReference1.CxfWebServiceApiClient Client = new ServiceReference1.CxfWebServiceApiClient();
using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)Client.InnerChannel))
{
System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add("code", encryptionKey);
return Client.getSycps("A475FF7995EA4F8686F1A5DB67EB32F4");
}
}


However, VS reports an error:

Error details: System.ServiceModel.CommunicationException: 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. ---> System.ServiceModel.QuotaExceededException: 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 found a solution by editing the App.config. I edited it as below:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="CxfWebServiceImplApiPort" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
<customBinding>
<binding name="CxfWebServiceImplApiServiceSoapBinding">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="***" binding="customBinding" bindingConfiguration="CxfWebServiceImplApiServiceSoapBinding" contract="ServiceReference1.CxfWebServiceApi" name="CxfWebServiceImplApiPort" />
</client>
</system.serviceModel>

Meanwhile, it still reports the same error. I don't know why it does not work any. How can I solve it? Thank you.

Continue reading...
 
Back
Top