简体   繁体   English

多个Windows服务使用具有多个端点的同一WCF?

[英]multiple windows services using same wcf with multiple endpoints?

Need some help with the best approach that someone may have taken in the past for the following problem... 需要某些人过去可能采取的最佳方法方面的帮助,以解决以下问题...

Hosting a WCF via a windows service calling a third party COM. 通过Windows服务调用第三方COM承载WCF。 The COM is unfortunately STAThead meaning that it only ever uses one core when run under one process scope. 不幸的是,COM是STAThead,这意味着在一个进程范围内运行时,它只能使用一个内核。

To get around the issue I want to duplicate the windows service (which I have easily done using differing service names during install) creating another process scope so the COM interop will use another core. 为了解决这个问题,我想复制Windows服务(在安装过程中我很容易使用不同的服务名称来完成此操作),创建另一个进程范围,以便COM互操作将使用另一个核心。

Problem: How do I host each service under a differing address so that clients can call whichever service they want to consume the WCF methods? 问题:如何将每个服务托管在不同的地址下,以便客户端可以调用他们要使用WCF方法的任何服务?

If I use differing endpoints and point each windows service at a different one I get an error message stating that only one host is allow for each base address. 如果我使用不同的端点并将每个Windows服务指向一个不同的端点,则会收到一条错误消息,指出每个基地址只允许一个主机。

Can I add multiple base address (differing port maybe) for the same protocol and still link them to differing host services? 是否可以为同一协议添加多个基地址(可能有不同的端口),并且仍将它们链接到不同的主机服务?

Examples would be great :). 例子将是巨大的:)。

It sounds to me like you really want to have multiple instances of this COM object used by the WCF service. 在我看来,您确实希望WCF服务使用此COM对象的多个实例。 You could spin up new threads (each STA) that instantiate and use their own COM object so that you can be using more than one of these COM objects at once. 您可以启动实例化并使用它们自己的COM对象的新线程(每个STA),以便可以一次使用多个COM对象。 You, of course, will have to communicate any results back to the WCF thread. 当然,您必须将所有结果传达回WCF线程。

If you want to host more than one instance of the WCF Service, it depends on how you're hosting. 如果您要托管多个WCF服务实例,则取决于您的托管方式。 In ii6, you can simply create another .svc file. 在ii6中,您可以简单地创建另一个.svc文件。 That will run the service in the same process as everything else in that application pool. 这将在相同的工艺,该应用程序池一切运行服务。 You can get the service to run in a different process by assigning it a different application pool. 通过为服务分配不同的应用程序池,可以使该服务在不同的进程中运行。 I'm not sure if you can do this on a per .svc basis. 我不确定是否可以在每个.svc的基础上执行此操作。 If you're using IIS 7 you can either do the .svc thing or use the Windows process activation service (WAS) support in IIS7, in which case you basically create another element in the config. 如果您使用的是IIS 7,则可以执行.svc或在IIS7中使用Windows进程激活服务(WAS)支持,在这种情况下,您基本上可以在配置中创建另一个元素。 I believe you can use WAS in Windows Server 2008 R2 without really using IIS... 我相信你可以使用在Windows Server 2008 R2是没有真正使用IIS ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM