WCF 是否适合实现遗留网络服务?
我使用术语“网络服务”来指代诸如 NNTP、IMAP、POP3 之类的事物,这些事物在 TCP/IP 之上具有定义的协议。
我很难弄清楚如何使用 WCF 客户端连接到现有网络服务。 除了基本上使用 C# 化套接字代码的示例之外,我还没有找到任何示例。
任何人都可以向我推荐使用 WCF 与遗留服务(而不是美化的套接字)进行对话的任何示例吗?
WCF 是否适合这种类型的需求?
谢谢。
I use the term network services to refer to things such as NNTP, IMAP, POP3... things which have a defined protocol layered on top of TCP/IP.
I'm having a very difficult time figuring out how I can connect to an existing network service using a WCF client. I haven't found any examples other than ones that are basically using C#-ified socket code.
Can anyone refer me to any examples of using WCF to talk to a legacy service as something other than a glorified socket?
Is WCF even appropriate for this type of requirement?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,术语“WCF”实际上意味着两件事:
没有内置的协议绑定您提到的,这就是为什么您将看到的示例看起来像“美化的套接字” - 这就是它们的本质。 这就是绑定:基于基本协议(通常是 UDP/IP 或 TCP/IP)构建的抽象级别。
现在,话虽如此,您需要构建/借用/窃取/任何可与您选择的协议一起使用的绑定。 这可能看起来像是您只是将套接字注入到 WCF 框架中,老实说,这就是它的本质:)...那么它有什么好处呢?
如果您成功地实现了对规范的绑定,您就得到了一个非常容易替换的组件,它将适合所有 WCF 应用程序。 无论您是否想要这种行为,都取决于您和您的要求:)
祝您好运。
Well, the term "WCF" actually means 2 things:
There's not built in bindings for the protocols you mentioned, which is why the examples you'll see looks like "glorified sockets" - That's what they are. That's what a binding is: A level of abstraction built on a basic protocol (typically UDP/IP or TCP/IP).
Now, with all this being said, you need to build / borrow / steal / whatever a binding that is usable with your protocol of choice. This might look like you're just injecting sockets into the WCF framework, and honestly, that's just what it is :)... So what's so great about it?
If you managed to implement your binding to-the-specs, you got yourself a very easily substituted component, which will fit into all WCF applications. Whether you want this behaviour or not, is up to you and your requirements :)
Good luck with it.
WCF 的核心是 Microsoft 提供的基于 SOAP 的统一通信引擎 - 它取代了 ASMX Web 服务、WSE、.NET Remoting 等。
因此,它是基于 SOAP 的,因此可以与任何使用 SOAP 进行通信的东西进行通信——我怀疑 POP3 或其他服务是否属于这种情况。 因此,我认为您实际上无法为这些服务编写 WCF 客户端。
至于从头开始编写这些服务并将它们公开为 WCF 服务 - 这可能会起作用,因为基本上 WCF 服务实现可以做任何事情,然后将自己作为 SOAP 服务呈现给外界 - 可能会起作用,问题是:有什么好处?
马克
Well, WCF at its heart is the unified communication engine offering by Microsoft, based on SOAP - it replaces ASMX web services, WSE, .NET Remoting and more.
As such, it's SOAP based and therefore can talk to anything that talks SOAP - which I doubt is the case for POP3 or other services. So I don't think you can write a WCF client for these services, really.
As for writing these services from scratch and exposing them as WCF services - that might work, since basically the WCF service implementation can do anything, and then present itself to the outside world as a SOAP service - could work, question is: what's the benefit?
Marc
WCF 附带了一组标准绑定,以下是 3.5 中提供的绑定列表:
http://msdn.microsoft.com/en-us/library/ms730879.aspx
如果您需要使用其他任何东西,WCF 可能不是最佳选择。 即使您可以构建自己的绑定,成本也将超过收益。
如果您的项目要求所有内容都应使用 WCF,则可以在套接字代码上构建 WCF 外观。
WCF comes with a set of standard bindings, here is a list of the bindings provided in 3.5:
http://msdn.microsoft.com/en-us/library/ms730879.aspx
If you need to use anything else, WCF is probably not the way to go. Even if you could build your own binding, the cost would outweigh the benefit.
If you have a requirement in your project that everything should use WCF, you could build a WCF facade over your sockets code.