在 Azure 上的 WCF 中通过 SSL 配置 webHTTP 和 NetHTTP 绑定
Posted
技术标签:
【中文标题】在 Azure 上的 WCF 中通过 SSL 配置 webHTTP 和 NetHTTP 绑定【英文标题】:Configuring both webHTTP and NetHTTP bindings over SSL in WCF on Azure 【发布时间】:2011-01-09 04:32:53 【问题描述】:我们希望通过 REST 和 TCP 公开我们的 WCF 服务,并使用 SSL 保护它们。我们已将有效的 SSL 上传到 Azure 和正确的映射设置,以便转到 https://service.ourdomain.com 正常工作。
我已经设置了两个端点绑定,用于 REST 服务的 webHttpBinding 和用于 TCP 的 NetHttpBinding 类型的 customBinding。
我认为我的 SSL 可以与 webHTTP 一起使用,但是当我尝试在 NetHTTP 的自定义绑定中启用 httpsTransport 时出现错误
“无法添加传输元素“httpTransport”。绑定中已存在另一个传输元素每个绑定只能有一个传输元素”
所有配置都在WebRole web.config中完成 我查看了 Silverlight 人员在此处提交的其他 WCF 问题,他们通过 SSL 提供了 webHTTP 的帮助,但二进制的东西让我很难过。
是否可以从同一个 SSL 域同时运行 REST 和 TCP WCF 服务,如果可以,我很想知道?
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="SecureWebHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
<customBinding>
<binding name="NetHttpBinding">
<binaryMessageEncoding />
<!--<httpsTransport authenticationScheme="None" />-->
</binding>
</customBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="RestService">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="BinaryService">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="RestService" name="WebService.Rest">
<endpoint address="Achievements"
binding="webHttpBinding"
bindingConfiguration="SecureWebHttpBinding"
behaviorConfiguration="webBehavior"
contract="WebService.JSON.IAchievementJSON"/>
</service>
<service behaviorConfiguration="BinaryService" name="WebService.Binary">
<endpoint address="Achievements"
binding="customBinding"
bindingConfiguration="NetHttpBinding"
contract="WebService.BinaryInterfaces.IAchievementBinary"/>
</service>
</services>
</system.serviceModel>
【问题讨论】:
【参考方案1】:两个绑定的端点地址相同。尝试将其中一个更改为 Achievements/bin 或其他内容。这应该可以解决您的问题。
【讨论】:
以上是关于在 Azure 上的 WCF 中通过 SSL 配置 webHTTP 和 NetHTTP 绑定的主要内容,如果未能解决你的问题,请参考以下文章
在 Service Fabric 中通过 HTTPS 调用 WCF:请求被中止:无法创建 SSL/TLS 安全通道
设置 SSL 以在 Azure 上使用 WCF 的步骤是啥?
有时调用 Microsoft Azure 托管的 WCF 服务会导致“SSL/TLS 的信任关系”问题