为HTTPS更改WCF maxReceivedMessageSize

时间:2016-07-18 07:50:26

标签: wcf https web-config wcf-binding

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

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

Web配置具有协议映射:

<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:服务   &#39; MyServiceNamespace.RequestProcessorImpl&#39;没有申请   (非基础设施)端点。这可能是因为没有配置   找到了您的应用程序的文件,或者因为没有服务元素   匹配服务名称可以在配置文件中找到,或者   因为没有在服务元素中定义端点。

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

1 个答案:

答案 0 :(得分:1)

感谢Tim his post让我回答。

对我来说,关键是在定义为&lt; basicHttpsBinding &gt;的绑定中省略' name '属性:

   c.setBackground(Color.GREEN);

然后覆盖协议映射指向的默认值。