tags:

views:

153

answers:

3

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.

A: 

Well, the term "WCF" actually means 2 things:

  • The framework: "ABC" - Address, binding, contract
  • Actual use of a combination of the above (for example, a WCF webservice using BasicHttpBinding)

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.

cwap
+1  A: 

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.

Shiraz Bhaiji
There are several community-supplied additions to those bindings, too - things like UdpBinding, SmtpBinding and many more - of excellent quality. Don't Repeat Yourself - chances are, someone's already done that work for you!
marc_s
A: 

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

marc_s
It's more than SOAP - I'm using WCF for REST at the moment!
Jeremy McGee
True - but right now, it's just a "preview" package - should be part of the .NET 4.0 shipping WCF though (later this year 2009)
marc_s