【问题标题】:Change WCF maxReceivedMessageSize for HTTPS更改 HTTPS 的 WCF maxReceivedMessageSize
【发布时间】:2016-07-18 07:50:26
【问题描述】:

如何更改 web.config 以在我的 WCF 网络服务中为 https 定义 maxReceivedMessageSize?

我有一个跨 HTTPS 运行的 WCF 4 Web 服务,我想为绑定设置 maxReceivedMessageSize

网络配置有一个协议映射:

<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>

我已尝试删除映射并使用端点:

<services>
      <service name="Company.Product.Service">
      <host>
          <baseAddresses>
            <add baseAddress="https://mydomain/dir" />
          </baseAddresses>
      </host>
        <endpoint address="Service.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="IService">
        </endpoint>
      </service>
</services>

...

<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService" 
           maxBufferPoolSize="2147483647" 
           maxBufferSize="2147483647" 
           maxReceivedMessageSize="2147483647" 
           messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            <security mode="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None" />
            </security>
        </binding>
      </basicHttpBinding>

但是当我删除协议映射时,我得到:

服务无法启动。 System.InvalidOperationException:服务 “MyServiceNamespace.RequestProcessorImpl”的应用程序为零 (非基础设施)端点。这可能是因为没有配置 为您的应用程序找到了文件,或者因为没有服务元素 可以在配置文件中找到匹配的服务名称,或者 因为在服务元素中没有定义端点。

如何更改配置以在我的 WCF Web 服务中为 https 定义 maxReceivedMessageSize?

【问题讨论】:

    标签: wcf https web-config wcf-binding


    【解决方案1】:

    感谢 Tim his post 让我得到了答案。

    对我来说关键是在定义为 basicHttpsBinding> 的绑定中省略“name”属性:

    <basicHttpsBinding>
            <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
              <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <security mode="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None" />
                    <message clientCredentialType="Certificate" algorithmSuite="Default" />
                </security>
            </binding>
    

    这会覆盖协议映射指向的默认值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-09
      • 1970-01-01
      • 1970-01-01
      • 2011-11-13
      • 2023-03-22
      • 2013-09-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多