9

在我的 WCF 服务中,我试图通过 SSL 连接使用 JSON 向客户端发送数据。我能够wsHttpBinding使用Transport. 为什么webHttpBinding不能做同样的事情来使用 SSL?我将如何配置需要使用 JSON 来使用 SSL 连接的端点?

webHttpBinding本质上和有什么区别wsHttpBinding

<bindings>
  <wsHttpBinding>
    <binding name="TransportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>

  <endpointBehaviors>
    <behavior name="EndpBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>

<services>
  <service behaviorConfiguration="ServiceBehavior" name="DataService4.DataService">

    <endpoint address="" binding="webHttpBinding" contract="DataService4.IService" bindingConfiguration="TransportSecurity" behaviorConfiguration="EndpBehavior" />

    <endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex" />   
  </service>
</services>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

4

2 回答 2

12

我想这篇文章会解决你的问题。 创建 WCF RESTful 服务并使用 HTTPS 通过 SSL 对其进行保护

于 2013-09-30T17:07:41.080 回答
12

http://www.allenconway.net/2012/05/creating-wcf-restful-service-and-secure.html的相关部分是这样的:

<bindings>
  <webHttpBinding>
    <binding>
      <security mode="Transport" />
    </binding>
  </webHttpBinding>
</bindings> 

但如果需要,还可以删除暴露的元数据。

详细信息记录在 msdn 中:https ://msdn.microsoft.com/en-us/library/bb924478(v=vs.110).aspx

相关部分是:

使用 HTTPS 提供传输安全性。该服务需要配置 SSL 证书。消息完全使用 HTTPS 进行保护,并且服务由客户端使用服务的 SSL 证书进行身份验证。客户端身份验证通过webHttpBinding 传输的 ClientCredentialType 属性进行控制。

于 2016-05-03T20:05:08.860 回答