WCF 服务无法在 HTTPS/SSL 下运行

标签 wcf silverlight iis ssl https

我有一个在我的 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/

相关文章:

asp.net - ASP.NET MVC 中的 404 页

c# - WCF 服务 : (413) Request Entity Too Large 返回意外响应

c# - namespace 在项目中不可见。 (命名空间中不存在类型或命名空间名称)

c# - 我可以从 Silverlight 中的 BitmapImage 获取 byte[] 吗?

c# - LongListSelector 和 ContextMenu 返回错误的项目

从命令行表达 IIS

c# - 添加为服务引用时 WCF 消息协定缺少 header

wcf - 具有自定义绑定(bind)的 SSL WCF

.net - 类型 XX 存在于两个 DLL 中

asp.net-core - 运行运行时包后 iis 模块中缺少 aspnetcoremoduleV2