C# SAP SOAP MaxReceivedMessageSize,在哪里添加?

C# SAP SOAP MaxReceivedMessageSize, where to add it?

我已经从 WSDL 文件导入了 SAP SOAP 服务,现在一切正常,直到超过默认限制。

我收到以下错误:

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.

通常我会更改我的 app.config 文件并添加更高的限制,但它似乎不起作用。

那么应该添加到哪里呢?

QueryMarketingLeadInClient m_SAP_Query = new QueryMarketingLeadInClient("binding");

app.config

<system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="binding_SOAP12">
                    <mtomMessageEncoding />
                    <httpsTransport authenticationScheme="Basic" />
                </binding>
                <binding name="binding">
                    <mtomMessageEncoding messageVersion="Soap11WSAddressing10" />
                    <httpsTransport authenticationScheme="Basic" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="https://sap.adrress.here"
                binding="customBinding" bindingConfiguration="binding_SOAP12"
                contract="QueryMarketingLeadIn" name="binding_SOAP12" />
            <endpoint address="https://sap.adrress.here"
                binding="customBinding" bindingConfiguration="binding" contract="QueryMarketingLeadIn"
                name="binding" />
        </client>
    </system.serviceModel>

所以我找到了问题的答案。问题是在 CustomBinding 中 app.config 设置不同于普通的 Binding

这个post是关键:

使用 <httpsTransport><mtomMessageEncoding> 元素在内部绑定元素中完成配置

我已经把我的 app.config 改成了这个

<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="binding_SOAP12">
                <mtomMessageEncoding maxBufferSize="2147483647">
                  <readerQuotas maxStringContentLength ="2147483647"/>
                </mtomMessageEncoding>
                <httpsTransport authenticationScheme="Basic" maxReceivedMessageSize ="2147483647" />
            </binding>
            <binding name="binding">
                <mtomMessageEncoding messageVersion="Soap11WSAddressing10" maxBufferSize="2147483647">
                  <readerQuotas maxStringContentLength ="2147483647"/>
                </mtomMessageEncoding>
                <httpsTransport authenticationScheme="Basic" maxReceivedMessageSize ="2147483647"/>
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="https://sap.adrress.here""
            binding="customBinding" bindingConfiguration="binding_SOAP12"
            contract="QueryMarketingLeadIn" name="binding_SOAP12" />
        <endpoint address="https://sap.adrress.here""
            binding="customBinding" bindingConfiguration="binding" contract="QueryMarketingLeadIn"
            name="binding" />
    </client>
</system.serviceModel>