我有一个在我的 Silverlight 项目中使用的 WCF 服务。我几乎遵循了有关如何为 WCF 服务设置 https 和 ssl 的所有信息。如果不需要 SSL,则可以很好地调用该服务,但我在检查与 fiddler 的通信时注意到 WCF 服务仍在 http 协议(protocol)中。此外,如果我启用 SSL,则无法在浏览器中浏览 WCF 服务(在 VS2010 中右键单击 -> 选择浏览)。
我怀疑该服务仍在使用 http 协议(protocol)在某些内部方法上被调用。
关于如何解决这个问题有什么建议吗?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="AuthService.customBinding" >
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="AuthService">
<endpoint address="" binding="customBinding" bindingConfiguration="AuthService.customBinding" contract="AuthService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
谢谢
最佳答案
您使用自定义绑定(bind)的任何具体原因。您的服务名称属性和契约(Contract)属性也需要完全限定。
如果您希望 WCF 服务符合也允许非 .NET 客户端访问的基本配置文件 1.1,则可以使用简单的 basicHttpBinding。
关于WCF 服务无法在 HTTPS/SSL 下运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9405298/