通过https访问AppHarbor上的WCF服务

通过https访问AppHarbor上的WCF服务,wcf,ssl,appharbor,Wcf,Ssl,Appharbor,我正在尝试使用传输安全模型保护我的WCF服务。我已成功将我的服务部署到AppHarbor。但当我尝试访问服务页面时,出现以下异常: [InvalidOperationException:找不到与绑定BasicHttpBinding的终结点的方案https匹配的基址。注册的基址方案为[http]。] 我没有上传任何证书,只是在那里使用了搭载SSL。我已经下载了构建并在我的机器上部署了它。它很好用 以下是web.config的my system.serviceModel部分: <system.

我正在尝试使用传输安全模型保护我的WCF服务。我已成功将我的服务部署到AppHarbor。但当我尝试访问服务页面时,出现以下异常:

[InvalidOperationException:找不到与绑定BasicHttpBinding的终结点的方案https匹配的基址。注册的基址方案为[http]。]

我没有上传任何证书,只是在那里使用了搭载SSL。我已经下载了构建并在我的机器上部署了它。它很好用

以下是web.config的my system.serviceModel部分:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="TransportSecurity">
                <security mode="Transport">
                    <transport clientCredentialType="None"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration="AuthService.AuthServiceBehavior"  name="AuthService.AuthService">
            <host>
                <baseAddresses>
                    <add baseAddress="https://auth.apphb.com/AuthService.svc" />
                </baseAddresses>
            </host>
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="AuthService.IAuthService" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="AuthService.AuthServiceBehavior">
                <serviceMetadata httpsGetEnabled="true"/>        
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>


有人能解释一下我做错了什么吗?

你的方法不会马上奏效。这是因为SSL在负载平衡器处终止,并且应用服务器可以看到http流量。您可以阅读有关AppHarbor负载平衡器的更多信息

你也许可以


本讨论中还有一些提示:

当您通过LB与wcf web服务通信时,此问题经常出现(AppHarbor就是其中一个例子)

关于这种交流,你应该知道一些事情

1) 您的客户端应用程序和LB之间的通信是安全的(
https
正在使用)。因此,您应该在客户端利用安全绑定

总结我们所有的东西

客户端

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IAuthService">
                    <security mode="Transport">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://auth.apphb.com/AuthService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAuthService"
                contract="AuthService.IAuthService" name="BasicHttpBinding_IAuthService" />
        </client>
    </system.serviceModel>
</configuration>

服务器

<system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <protocolMapping>
      <add scheme="http" binding="basicHttpBinding" />
    </protocolMapping>
    <bindings>
      <basicHttpBinding/>
    </bindings>
    <services>
      <service behaviorConfiguration="AuthService.AuthServiceBehavior" name="AuthService.AuthService">
        <endpoint binding="basicHttpBinding" contract="AuthService.IAuthService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="AuthService.AuthServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IAuthService">
                    <security mode="Transport">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://auth.apphb.com/AuthService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAuthService"
                contract="AuthService.IAuthService" name="BasicHttpBinding_IAuthService" />
        </client>
    </system.serviceModel>
</configuration>
<system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <protocolMapping>
      <add scheme="http" binding="basicHttpBinding" />
    </protocolMapping>
    <bindings>
      <basicHttpBinding/>
    </bindings>
    <services>
      <service behaviorConfiguration="AuthService.AuthServiceBehavior" name="AuthService.AuthService">
        <endpoint binding="basicHttpBinding" contract="AuthService.IAuthService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="AuthService.AuthServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>