【问题标题】:Host multiple services in same Application using IIS 7.5使用 IIS 7.5 在同一应用程序中托管多个服务
【发布时间】:2012-01-22 01:56:25
【问题描述】:

我有一个带有 5 个 WCF 服务的 Visual Studio 解决方案。它们都在同一个项目“MyCompany.MySoftware.Services”中。

这一次,我将它们全部托管在 IIS 中(我习惯于使用 Windows 服务进行托管,但我计划使用 AppFabric,因此我决定更改)并且我已启用使用 HTTP 和 Net.TCP 绑定。

各项服务的配置如下:

<service name="Kipany.Belvedere.Services.Services.AppointmentService"
         behaviorConfiguration="GeneralBehavior">
  <endpoint address="" binding="wsHttpBinding" 
            contract="Company.Software.Services.IService1" 
            name="appointmenthttp"/>
  <endpoint address="" binding="netTcpBinding" 
            bindingConfiguration="netTcpBindingConfig" 
            name="appointmenttcp" 
            contract="Company.Software.Services.IService1"/>
  <endpoint address="mex" binding="mexHttpBinding" 
            contract="IMetadataExchange"/>
</service>

<service name="Kipany.Belvedere.Services.Services.AppointmentService"
         behaviorConfiguration="GeneralBehavior">
  <endpoint address="" binding="wsHttpBinding" 
            contract="Company.Software.Services.IService5" 
            name="appointmenthttp"/>
  <endpoint address="" binding="netTcpBinding" 
            bindingConfiguration="netTcpBindingConfig" 
            name="appointmenttcp" 
            contract="Company.Software.Services.IService5"/>
  <endpoint address="mex" binding="mexHttpBinding" 
            contract="IMetadataExchange"/>
</service>

我在这篇文章中读到,在 IIS 中托管时,我必须让我的 netTcp 端点没有地址。目前,我的 IIS 配置了 808 端口,所以我知道我所有的服务都在使用这个端口。

问题:

1 - 这是一个很好的架构吗? 2 - 我可以面对这个配置的问题吗? 3 - 如果我想在不同的 tcp 端口中使用每个服务怎么办? 4 - tcp 绑定的端口是在默认网站中配置的,但我可以选择在端点中填写“地址”,在这种情况下会发生什么?由于我必须在默认网站绑定中放置一个端口,我如何在我的 Web.Config 中使用多个端口? 5 - 我的 tcp 使用 808 端口,但这是我客户端的 Web.Config:

808端口在哪里?

【问题讨论】:

    标签: wcf iis net.tcp


    【解决方案1】:
    1. 这个架构很好
    2. 配置中没有任何内在因素会导致您出现问题
    3. TCP 使用的端口是在 IIS 中的站点级别配置的(站点绑定),因此服务必须位于不同的站点才能使用不同的端口 - 端口和地址的其余部分用于路由请求因此,不同端口上的服务没有固有的优势
    4. 如 3 所述 - 一个站点中的所有服务都将使用相同的端口
    5. 客户端需要完全限定地址,但在 IIS 托管中,服务地址(包括端口)的定义是从 IIS 配置和 .svc 文件中推断出来的

    【讨论】:

    • 所以只有一个端口可以轻松处理所有请求?并发呢?同时完成的两个请求将并行处理还是一个等待另一个?
    • 这一切都取决于您的服务的实例化和并发设置(我在此写了博客 dotnetconsult.co.uk/weblog2/…)但当然没有根本原因您不能并行处理请求
    猜你喜欢
    • 2011-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-18
    相关资源
    最近更新 更多