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

时间:2016-04-13 11:47:05

标签: c# soap sap

我已经从WSDL文件中推出了SAP SOAP服务,并且每个签名都正常工作,直到超出默认限制。

我收到以下错误:

  

已超出传入邮件的最大邮件大小限额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。

通常我会更改我的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>

1 个答案:

答案 0 :(得分:0)

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

这篇文章是关键:https://stackoverflow.com/a/25359548/4845680

使用<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>