【问题标题】:WCF Service won't work under HTTPS / SSLWCF 服务在 HTTPS / SSL 下不起作用
【发布时间】:2012-02-23 00:14:22
【问题描述】:

我在 Silverlight 项目中使用了 WCF 服务。我已经关注了有关如何为 WCF 服务设置 https 和 ssl 的几乎所有信息。如果不需要 SSL,可以很好地调用该服务,但我在检查与提琴手的通信时注意到 WCF 服务仍处于 http 协议中。此外,如果我启用 SSL,则无法在浏览器中浏览 WCF 服务(在 VS2010 中右键单击 -> 选择浏览)。

我怀疑该服务仍在使用 http 协议的某些内部方法调用。

对如何解决这个问题有什么建议吗?

<?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>

谢谢

【问题讨论】:

  • 您使用自定义绑定的任何具体原因。您的服务名称属性和合同属性也需要完全限定
  • Rajesh,完全限定名称使其正常工作。当谈到服务器端编码和 web.config 文件时,我很绿色。我应该只使用 basichttpbinding 还是 wshttpbinding。也许我会去阅读 WCF 配置架构。谢谢 Rajesh,我想将您的评论标记为答案。
  • 你的意思是它现在可以正常工作还是通过https 尝试仍然无法正常工作
  • 它适用于 SSL 设置为 required 并且我检查了 fiddler 及其使用 https 协议。 :)
  • 我会发布相同的答案,如果您可以将其标记为答案,那就太好了

标签: wcf silverlight iis ssl https


【解决方案1】:

您使用自定义绑定的任何具体原因。您的服务名称属性和合同属性也需要完全限定。

如果您希望 WCF 服务与允许非 .NET 客户端访问的基本配置文件 1.1 兼容,则可以使用简单的 basicHttpBinding。

【讨论】:

  • name属性和contract属性需要全限定XD
猜你喜欢
  • 1970-01-01
  • 2012-09-03
  • 1970-01-01
  • 1970-01-01
  • 2011-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多