【问题标题】:ISA Web Farm and WCF service hosted in a Windows Service with basicHttpBindingISA Web Farm 和 WCF 服务托管在具有 basicHttpBinding 的 Windows 服务中
【发布时间】:2011-01-31 00:42:12
【问题描述】:

我创建了一个 WCF 服务,该服务需要托管在窗口服务中,因为它参与了 P2P 网格 (NetPeerTcpBinding)。当我尝试在 IIS 服务容器中使用 NetPeerTcpBinding 端点托管 WCF 服务时,该服务无法运行,因为事实证明 P2P 绑定在 IIS 中不起作用。

我已经从托管在 Windows 服务容器中的 WCF 服务公开了一个 HTTP 端点,我想知道是否有一种方法可以创建一个 ISA Web Farm,它将流量路由到两台运行相同 WCF 的机器上的 http 端点Windows 服务容器中的服务。

【问题讨论】:

  • 为什么你的问题标题是basicHttpBinding,而你却说你有一个暴露netPeerTcpBinding的Windows服务?
  • wcf 服务两者都有。它使用一个合约参与网格,并使用一个不同的、更有限的合约公开一个 basicHttpBinding 端点。

标签: wcf web-farm


【解决方案1】:

我很久以前就知道这个问题了,很抱歉花了这么长时间才发布答案。

创建一个名为 IDefaultDocumentService 的单独服务合同,其中包含一个方法,该方法同时使用 OperationContract 和 WebGet 进行修饰。

<OperationContract(), WebGet()> 
Function GetDefaultDocument() As System.ServiceModel.Channels.Message

现在在一个非常简单的 DefaultDocumentService 类中实现该联系人

Public Class DefaultDocumentService
    Implements IDefaultDocumentService

    Public Function GetDefaultDoc() As Message Implements IDefaultDocumentService.GetDefaultDocument
        Return Message.CreateMessage(MessageVersion.None, "", "Hello!")
    End Function
End Class

在 Windows 服务的配置文件中,为 DefaultDocumentService 连接一个单独的服务,并将其映射到其他 WCF 服务的根目录。当您将这些服务放入 ISA 上的 Web Farm 时,它将访问您的默认文档服务并获得“Hello!”。消息足以让 ISA 服务器知道服务处于活动状态。

<system.serviceModel>
  <services>
    <service name="YourMainService">
      <endpoint address="http://localhost:10000/YourMainService.svc"
                binding="wsHttpBinding"
                contract="IYourMainService" />
    </service>

    <service name="DefaultDocumentService">
      <endpoint address="http://localhost:10000/"
                binding="webHttpBinding"
                behaviorConfiguration="DefaultDocumentEndpointBehavior"
                contract="IDefaultDocumentService" />
    </service>
  </services>

  <behaviors>
    <endpointBehaviors>
      <behavior name="DefaultDocumentEndpointBehavior">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
  </behaviors>
</system.serviceModel>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多