.netwcfsoapmtommaxreceivedmessagesize

The maximum buffer size has been exceeded while reading MTOM data


I have to consume an external web service, but I'm getting the following error:

The maximum buffer size (65536) has been exceeded while reading MTOM data

Before today, I was consuming the same service using the following configuration:

    <bindings>
        <basicHttpBinding>
            <binding name="BOServiceSoap11Binding">
                <security mode="Transport" />
            </binding>
            <binding name="BOServiceSoap11Binding1" />
        </basicHttpBinding>
        <customBinding>
            <binding name="BOServiceSoap12Binding">
                <mtomMessageEncoding messageVersion="Soap12" />
                <httpsTransport />

            </binding>
        </customBinding>
    </bindings>

Here is my endpoind:

<endpoint address="https://x.com/live-api/services/BOService.BOServiceHttpsSoap12Endpoint/"
            binding="customBinding" bindingConfiguration="BOServiceSoap12Binding"
            contract="xServiceReference.BOServicePortType" name="BOServiceHttpsSoap12Endpoint" />

I tried to increase the MaxReceivedMessageSize by adding the following tags to the customBinding tag and the children of it:

MaxReceivedMessageSize="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBufferSize="2147483647"

How do I have to configure my endpoint to get reponse properly?

Thanks,


Solution

  • I changed my configuration as below:

      <customBinding>
        <binding name="BOServiceSoap12Binding">
          <mtomMessageEncoding messageVersion="Soap12" maxBufferSize="2147483647"/>
          <httpsTransport maxReceivedMessageSize="2147483647"/>
        </binding>
      </customBinding>
    

    Everything works as expected now.