WCF - 不使用 IIS 的远程服务 - 基地址?

发布于 2024-08-26 16:30:04 字数 670 浏览 5 评论 0原文

我正在尝试了解 WCF 服务的寻址。

我们有一个客户端-服务器设置,其中服务器偶尔(可能每天一次)需要将数据推送到每个客户端。我希望在 NT 服务中托管的每个客户端上都有一个轻量级 WCF 侦听器服务来接收该数据。我们已经有了这样一个 NT 服务设置,托管一些用于其他任务的本地 WCF 服务,因此其开销是最小的。

由于服务器上现有的遗留代码,我认为该服务需要公开为 ASMX 并使用 basicHttpBinding 来允许它连接。

每个客户端都由用户在服务器上注册(他们需要单独配置它们),因此发现不是问题。

我的问题是,寻址是如何工作的?我想象用户以表单

http://0.0.0.0/MyService

或什至

http://hostname/MyService

在服务器上输入客户端地址。如果是这样,我如何在其 App.config 中配置客户端服务?我是否使用localhost

如果不是,那么向服务器公开服务的推荐方式是什么?

注意:

  • 我不想在 IIS 中托管,因为这会给客户端所需的硬件增加额外的要求。
  • 客户端几乎肯定位于 LAN 上,而不是公共互联网上

I'm trying to get my head around the addressing of WCF services.

We have a client-server setup where the server occasionally (maybe once a day) needs to push data to each client. I want to have a lightweight WCF listener service on each client hosted in an NT service to receive that data. We already have such an NT service setup hosting some local WCF services for other tasks so the overhead of this is minimal.

Because of existing legacy code on the server I believe the service needs to be exposed as ASMX and use basicHttpBinding to allow it to connect.

Each client is registered on the server by the user (they need to configure them individually) so discovery is not the issue.

My question is, how does the addressing work? I imagine the user entering the client's address on the server in the form

http://0.0.0.0/MyService

or even

http://hostname/MyService

If so, how do I configure the client service in its App.config? Do I use localhost?

If not then what is the reccommended way of exposing the service to the server?

Note:

  • I don't want to host in IIS as that adds extra requirements to the hardware required for the client.
  • The clients will be almost certainly located on LANs, not over the public internet

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命硬 2024-09-02 16:30:04

您可以像这样配置服务的基地址:

<system.serviceModel>
  <services>
    <service name="Ns.FooService">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:9999" />
        </baseAddresses>
      </host>
      <endpoint
          address="/foo"
          binding="basicHttpBinding"
          contract="Ns.IFooContract" />
     </service>
  </services>
</system.serviceModel>

然后可以通过http://servename:9999/foo访问您的服务。您可以查看本文了解更多信息。

You configure the base address of the service like so:

<system.serviceModel>
  <services>
    <service name="Ns.FooService">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:9999" />
        </baseAddresses>
      </host>
      <endpoint
          address="/foo"
          binding="basicHttpBinding"
          contract="Ns.IFooContract" />
     </service>
  </services>
</system.serviceModel>

And then your service could be accessible through http://servename:9999/foo. You may take a look at this article for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文