我正在尝试使用传输安全模型来保护我的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>
我已经尝试了这个Hosting a WCF Web API app on AppHarbor?
有人可以解释一下我做错了吗?
答案 0 :(得分:4)
当您通过LB(其中一个示例的AppHarbor)与wcf Web服务进行通信时,经常会出现此问题。
您应该了解有关此类通信的一些事项。
1)您的客户端应用程序和LB之间的通信是安全的(https
正在使用中)。所以你应该在客户端利用安全绑定。
<basicHttpBinding> <binding name="BasicHttpBinding_IAuthService"> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </basicHttpBinding>
2)LB和网络前端之间的通信使用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>
答案 1 :(得分:1)
你的方法不会立即起作用。这是因为SSL在负载均衡器处终止,并且应用服务器看到http流量。您可以阅读有关AppHarbor负载均衡器here的更多信息。
此讨论中还有一些提示:http://support.appharbor.com/discussions/problems/829-transportwithmessagecredential-https-ssl