使用basicHttpBinding在Windows服务中托管的ISA Web Farm和WCF服务

时间:2010-03-23 22:01:17

标签: wcf web-farm isa

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

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

1 个答案:

答案 0 :(得分:0)

我认为这个问题已经退出了,很抱歉花了这么长时间才得到答案。

创建一个名为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配置文件中,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>