WCF中的Https绑定会引发错误

时间:2012-06-27 08:22:45

标签: wcf wcf-security

我有一个需要使用SSL使用basicHttpBinding托管的WCF服务。 因此,我的团队安装了SSL证书,启用了匿名身份验证,并在IIS中提供了硬编码的用户名和密码。 我尝试过这个绑定

 <binding name="SecurityByTransport">
               <security mode="Transport">
                 <transport clientCredentialType="Windows" />
                </security>
            </binding>   

但它仍然无效。我收到此错误“无法通过绑定BasicHttpBinding找到与端点的方案http匹配的基址。注册的基址方案为[https]。”

ServiceModel部分:

 <system.serviceModel>
<diagnostics>
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
  <customBinding>
    <binding name="netTcp">
      <binaryMessageEncoding>
        <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="64" />
      </binaryMessageEncoding>
      <security authenticationMode="UserNameOverTransport" />
      <windowsStreamSecurity />
      <tcpTransport portSharingEnabled="true" maxBufferPoolSize="52428800" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>
  </customBinding>

  <basicHttpBinding>
    <binding name="Https">
      <security mode="Transport">

      </security>
    </binding>
  </basicHttpBinding>

</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name ="Https">

      <serviceMetadata httpsGetEnabled="true"/>

      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Asi.Soa.ServiceModelEx.NullUserNamePasswordValidator, Asi.Soa.ServiceModelEx" />
        <clientCertificate>
          <authentication certificateValidationMode="None" />
        </clientCertificate>
      </serviceCredentials>
      <serviceAuthorization principalPermissionMode="Custom">
        <authorizationPolicies>
          <add policyType="Asi.Soa.ServiceModelEx.ClaimsAuthorizationPolicy, Asi.Soa.ServiceModelEx" />
        </authorizationPolicies>
      </serviceAuthorization>
      <exceptionShielding/>
    </behavior>


  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="SoapBehavior">

    </behavior>
    <behavior name="RestBehavior">

    </behavior>
    <behavior name="AjaxBehavior">
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
</behaviors>
<services>


  <service name="Asi.Soa.Core.Services.EntityService" >
    <endpoint address="https://10.42.150.122/imis15/EntityService.svc" binding="basicHttpBinding" contract="Asi.Soa.Core.ServiceContracts.IEntityService"
       bindingConfiguration="Https" />
  </service>

</services>

任何帮助都将不胜感激。

由于

3 个答案:

答案 0 :(得分:1)

尝试添加到服务行为设置

      <serviceMetadata httpsGetEnabled="true"/>

此外,您应该检查endpoind是否有设置

      bindingConfiguration="SecurityByTransport"

答案 1 :(得分:0)

如果您在IIS中托管服务,请尝试从站点绑定中删除http绑定。

HTH

答案 2 :(得分:0)

由于您在IIS上使用Web服务,因此考虑到您使用的是SSL证书,请使用HTTPS绑定。