有没有办法通过单个端点公开多个 WCF 服务?
我目前通过 WCF 提供多种方法的服务。我想进行重构,以便将单个服务分为多个类,每个类提供一组不同的功能。但是,我希望仍然与客户端保持单一连接。这可能吗?
我想答案是否定的,那么我该如何解决这个问题呢?有解决方法吗?或者我的想法完全愚蠢,我应该改变应用程序的设计?
I currently offer a service with many methods via WCF. I'd like to refactor so the single service is split into multiple classes, each offering a different set of functionality. However, I'd prefer to still have a single connection to the client. Is this possible?
I guess the answer is No, so how should I solve this issue? Is there a workaround? Or is my idea completely stupid and I should change the design of the application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请记住 E = ABC(端点 = 地址、绑定、合约)。使用不同的合同,即使其他条件相同,您仍然会得到不同的端点。
但是,单个服务可以实现多个服务契约。这将允许单个 .svc 文件成为多个不同服务合同的目标,所有服务合同都配置为相对于 .svc 的 URL。
Remember E = ABC (Endpoint = Address, Binding, Contract). With a different contract, even with all else equal, you've still got a different endpoint.
However, a single service can implement multiple service contracts. This would allow a single .svc file to be the target of several different service contracts, all configured as URLs relative to the .svc.
您可以实现部分类,它允许您将内容分离到各个 cs 文件中,同时维护单个接口和端点。这不是最理想的方式,因为最终它仍然是由部分类组成的单个类,但至少它在文件结构中看起来像它,从而提供了一些分离而不是一个巨大的类文件。
示例结构:
IMyService.cs
MyService.cs
UserService.cs
MessagingService.cs
You could implement partial classes that allow you to separate your content in individual cs files while maintaing a single interface and endpoint. This isn't the most ideal way, because at the end of the day it is still a single class made up of partial classes, but at least it looks like it in your file structure, thus giving some separation rather than a massive class file.
Example Structure:
IMyService.cs
MyService.cs
UserService.cs
MessagingService.cs