2

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

[InvalidOperationException:找不到与具有绑定 BasicHttpBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http].] ...

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

这是我的 web.config 的 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>

我已经尝试过在 AppHarbor 上托管 WCF Web API 应用程序?

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

4

2 回答 2

4

当您通过 LB(AppHarbor 的示例之一)与 wcf Web 服务进行通信时,经常会出现此问题。

您应该了解有关此类通信的几件事。

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

 <basicHttpBinding>
     <binding name="BasicHttpBinding_IAuthService">
         <security mode="Transport">
             <transport clientCredentialType="None" />
         </security>
     </binding> 
 </basicHttpBinding>

2) LB 和web-front 之间的通信使用http,所以服务器绑定应该basicHttpBinding没有额外的配置。

<endpoint binding="basicHttpBinding" contract="AuthService.IAuthService" />

总结我们拥有的所有东西

客户

<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>
于 2012-08-28T13:28:23.770 回答
1

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

你也许可以用这个模块来欺骗 WCF

在这个讨论中也有一些提示:http: //support.appharbor.com/discussions/problems/829-transportwithmessagecredential-https-ssl

于 2012-08-27T21:48:33.333 回答