none
Why the MaxReceivedMessageSize property no worked after I set it? RRS feed

  • Question

  • 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.

    Tuesday, July 9, 2019 6:47 AM

Answers

  • Hi mywatermelon,

    Thank you for posting here.

    Since this thread is related to WCF, I will move it to Windows Communication Foundation, Serialization, and Networking forum to get support.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    I found a solution here and it works:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/4f3b09da-4ab8-4338-b4c2-2b846f64e7a2/maxreceivedmessagesize-with-custom-binding?forum=wcf

    • Marked as answer by mywatermelon Tuesday, July 9, 2019 11:48 AM
    Tuesday, July 9, 2019 11:47 AM

All replies

  • Hi mywatermelon,

    Thank you for posting here.

    Since this thread is related to WCF, I will move it to Windows Communication Foundation, Serialization, and Networking forum to get support.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 9, 2019 7:41 AM
  • Hi mywatermelon,

    Thank you for posting here.

    Since this thread is related to WCF, I will move it to Windows Communication Foundation, Serialization, and Networking forum to get support.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thank you, hopes someone can help me.
    Tuesday, July 9, 2019 11:04 AM
  • Hi mywatermelon,

    Thank you for posting here.

    Since this thread is related to WCF, I will move it to Windows Communication Foundation, Serialization, and Networking forum to get support.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    I found a solution here and it works:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/4f3b09da-4ab8-4338-b4c2-2b846f64e7a2/maxreceivedmessagesize-with-custom-binding?forum=wcf

    • Marked as answer by mywatermelon Tuesday, July 9, 2019 11:48 AM
    Tuesday, July 9, 2019 11:47 AM