WCF 服务无法在 HTTPS / SSL 下工作

发布于 2025-01-08 14:54:43 字数 1825 浏览 1 评论 0原文

我有一个在 Silverlight 项目中使用的 WCF 服务。我已经关注了几乎所有有关如何为 WCF 服务设置 https 和 ssl 的信息。如果不需要 SSL,该服务可以完全正常调用,但我在检查与 fiddler 的通信时注意到 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>

谢谢

I have a WCF service that I'm using in my Silverlight project. I've followed pretty much any information on how to set up https and ssl for WCF services. The service can be called perfectly fine if SSL in not required but I noticed while examining the communications with fiddler that the WCF service was still in http protocol. Further more if I enable SSL the WCF service cant be browsed in a browser (right clicking in VS2010 -> selecting browse) .

My suspicion is that the service is still being called on some internal method with the http protocol.

Any suggestions to how to fix this?

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

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

堇色安年 2025-01-15 14:54:43

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

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

Any specific reason on why you are using a custom binding. Also your service name attribute and contract attribute needs to be fully qualified.

You can use simple basicHttpBinding if you want your WCF service to be compliant with basic profile 1.1 which allows non .NET clients to access as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文