在 Azure 上的 WCF 中通过 SSL 配置 webHTTP 和 NetHTTP 绑定

发布于 2024-08-19 03:14:47 字数 2469 浏览 3 评论 0原文

我们希望通过 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>

We would like to expose our WCF services over REST and also over TCP securing them both with SSL. We have a valid SSL uploaded to Azure and the proper mapping setup so that going to https://service.ourdomain.com works as it should.

I have setup two endpoint bindings, webHttpBinding for the REST services and a customBinding of type NetHttpBinding for the TCP.

I think I have SSL working with webHTTP but when I try and enable httpsTransport in the custom binding for NetHTTP I get the error

“Cannot add the transport element 'httpTransport'. Another transport element already exists in the binding There can only be one transport element for each binding”

All the config has been done in the WebRole web.config
I’ve had a look at the other WCF questions on here submitted by the Silverlight people and they helped with the webHTTP over SSL but the binary stuff has me stumped.

Is it possible to run both REST and TCP WCF services from the same SSL domain, if so I'd love to know?

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

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

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

发布评论

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

评论(1

挽心 2024-08-26 03:14:47

两个绑定的端点地址是相同的。尝试将其中之一更改为 Achievements/bin 或其他内容。这应该可以解决你的问题。

Your endpoint address for both bindings is the same. Try changing one of them to Achievements/bin or something. This should sort out your issue.

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