代码之家  ›  专栏  ›  技术社区  ›  Ryan Pedersen

在具有basichttpbinding的Windows服务中托管的ISA Web场和WCF服务

  •  0
  • Ryan Pedersen  · 技术社区  · 15 年前

    我已经创建了一个需要在窗口服务中托管的WCF服务,因为它正在参与P2P网格(netpeertcpbinding)。当我尝试在IIS服务容器中承载具有netpeertcpbinding端点的WCF服务时,该服务将无法运行,因为结果表明p2p绑定在IIS中不起作用。

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

    1 回复  |  直到 15 年前
        1
  •  0
  •   Ryan Pedersen    15 年前

    我早就知道这件事不干了,很抱歉我花了这么长时间才把答案公布出来。

    创建一个名为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场时,它将命中您的默认文档服务并得到一个“您好!”足以让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>
    
    推荐文章