提供给ServiceHost的baseAddresses不是Https

时间:2010-07-23 09:30:54

标签: c# .net wcf

我正在尝试将我的WCF服务配置为HTTPS。我已经使用相关地址配置了行为和服务,但我无法理解为什么提供给服务主机的地址仍然是http。

我正在使用的行为是:

    <behavior name="RequestProcessorBehavior">
      <serviceCredentials>
        <userNameAuthentication 
          userNamePasswordValidationMode="Custom" 
          customUserNamePasswordValidatorType="ServiceAuthentication,Services"/>
      </serviceCredentials>
      <serviceMetadata httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances="500"/>
    </behavior>

服务元素在这里

<service name="MyNamespace.WcfRequestProcessor" behaviorConfiguration="RequestProcessorBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="https://xxxxxxxxxxxxxx/Services/"/>
          </baseAddresses>
        </host>
        <!-- 
          Use the listenUri attribute if this causes a problem with the load balancer.
          The url of the listenUri should be that of the load balancer
        -->
        <endpoint address=""
                  bindingNamespace="https://xxxxxxxxxxxxxx/Services/"
                  contract="MyNamespace.IWcfRequestProcessor"
                  binding="basicHttpBinding"
                  bindingConfiguration="RequestProcessorBinding">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="wsHttpBinding"
                  bindingNamespace="https://xxxxxxxxxxxxxx/Services/"
                  contract="MyNamespace.IWcfRequestProcessor"
                  binding="wsHttpBinding"
                  bindingConfiguration="wsBinding">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>

当我在ServiceHost的构造函数中添加断点时,我可以看到baseAddresses参数只包含一个地址,即http而不是https。当我尝试访问svc页面时,我收到以下错误,我可以看到为什么它会显示但我无法看到我可以更改以使baseAddress传递给ServiceHost构造函数https而不是http。

  

无法找到该基地址   匹配端点的方案https   绑定BasicHttpBinding。   注册的基地址方案是   [HTTP]。

非常感谢任何帮助。


更新#1

我从原始问题中遗漏的绑定配置部分:

<bindings>
  <basicHttpBinding>
    <binding name="RequestProcessorBinding" maxReceivedMessageSize="2147483647" receiveTimeout="00:30:00" sendTimeout="00:30:00">
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

目前在开发环境和IIS6中。这是在默认网站内。

1 个答案:

答案 0 :(得分:1)