WCF 回调合约和服务器到服务器

发布于 2024-08-23 13:20:28 字数 276 浏览 5 评论 0原文

我正在开发一个包含多个 WCF 服务的解决方案,尽管它们属于不同类型,但它们都相互通信。这些服务通过 ChannelFactory 通用接口相互连接,并且每个服务都托管在 ServiceHost 内。

我的问题是,在服务器之间使用回调合约来相互通信是否正确,如果是,这样的解决方案会是什么样子。

目前我不喜欢这种实现,因为每个服务都需要托管几个具有不同接口的端点,一些端点用于其他服务,一些端点用于其他客户端。

当我尝试在 ServiceHost 内托管的服务类中实现回调契约时,它失败了。

I am developing a solution with multiple WCF services which all communicate among themselves, even though they are of different types. The services connect to one another through the ChannelFactory generic interface, and every service is hosted inside a ServiceHost.

My question is if it would be correct to use a callback contract among the servers to communicate with one another and if so how would such a solution look.

Currently I don't like the implementation because every service needs to host a couple of endpoints with different interfaces some for other services and some for other clients.

When I tried to implement the callback contract inside a service class that was hosted inside a ServiceHost it failed.

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

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

发布评论

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

评论(1

清风夜微凉 2024-08-30 13:20:28

首先,每当你发布一个问题说“它失败了”时,你需要告诉我们它是如何失败的。如果出现异常,则需要通过发布 ex.ToString() 的结果来发布整个异常,包括所有 InnerException 实例。

对于您的问题,我将实现一个服务合同,该合同代表每个服务中需要与其他服务通信的部分。还会有一个与该服务合约关联的回调合约。

这样,就好像每个服务都运行一个微型服务,仅用于服务到服务的通信。然后,他们每个人都可以利用服务之间传递的信息做自己的事情。

First of all, whenever you post a question saying, "it failed", you need to tell us in what way it failed. If there was an exception, then you need to post the entire exception, including all InnerException instances, by posting the result of ex.ToString().

To your problem, I'd implement a service contract that represents the part of each service that needs to talk to the other services. There would also be a callback contract associated with this service contract.

That way, it's as though each service operates a miniature service intended only for service-to-service communications. They can then each do their own thing with the information that is passed between the services.

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