owin 托管 API 控制器与常规无状态服务的 ServiceManifest 差异

Difference in ServiceManifest for owin hosted API controller vs regular stateless service

当您使用 vs 2015 在 Service Fabric 中创建 owin 托管 API 控制器时,ServiceManifest.xml 文件(在 Resources/Endpoints 下)中出现以下行:

<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="8726" />

但在常规无状态服务的情况下,相关 ServiceManifest.xml 文件中会出现以下行:

<Endpoint Name="ServiceEndpoint" />

既然两者都是底层的无状态服务,为什么 Endpoint 定义不同?这是什么意思?另外,我如何通过 http 传输调用第二个服务(从第一个服务)?

谢谢。

Web API 通常用作应用程序的网关,因此它需要一个固定端口,由负载均衡器映射到外部端口(与默认情况相反,随机端口由 Fabric 分配)。

此外,这可确保在 Windows 中正确注册 HTTP 端点,如 documentation:

中所述

This step is important because the service host process runs under restricted credentials (Network Service on Windows). This means that your service won't have access to set up an HTTP endpoint on its own. By using the endpoint configuration, Service Fabric knows to set up the proper access control list (ACL) for the URL that the service will listen on. Service Fabric also provides a standard place to configure endpoints.