tags:

views:

61

answers:

3

I looked up WCF and i cant exactly figured out what it is. I found this page and it seems to be a way for an app to allow other applications to call functions. Sort of loading a DLL and calling functions but using TCP instead and not loading a DLL but forcing a user to run an app.

I am still confused about it. Can someone explain what it is used for?

It looks like if i run two apps which can host the same service only the first will run the rest will get errors? I can call functions, but are there memory limitations? can i pass byte[] as params when allocated on stack or heap? I cannot pass file handles right? (I cant think of a reason why).

Can i have 3 apps be clients and fairly easily? like if i open app1 and open an image. Can i open app2 and 3 and have them do different things to the image currently loaded? (app 1) edit, 2) exported in memory image as different types (animated gif, avi, png, etc) 3) different editing tool or app to see how it will look at runtime

+3  A: 

WCF is really just a networking / communication platform. What you do with it is up to your requirements and skill. Typically it is used in situations where you have a client -> server or n-tier application. Most commonly it is hosted by IIS or Process Hosting service on a server. Then connected to by some client.

WCF does have the ability to transfer data, including images as a byte stream, etc, which it may sounds like what you were eluding too. You are also correct that it would not be correct to pass handles, since you are typically connecting applications across many boundaries (context, appdomain, machine, even domain / network).

Not sure what you are trying to understand about this, but hopefully it helps.

Ryan from Denver
It helps a lot. So this is really a method to call remote functions on remote servers and is typically not call code by an app on the local machine. That makes a lot of sense.
acidzombie24
So, what problem does WCF solve? What could you not do, say in .NET 2.0, when WCF was not there?
Prabhu
hmm, maybe message an app to say the song changed. Or write code to communicate with winamp through windows messaging. (i seen keyloggers do this for games by allowing /cmd to mean something which wont be printed to others on most games.). Also even now i dont see how global memory is possible without poking into win32
acidzombie24
@prabhu: in .NET 2.0 : nothing, since WCF was only introducted in .NET 3.0..... WCF is the "next generation" of ASMX web services, .NET remoting, WSE 3.0 extensions, message queuing etc. Those are all already available - but each has their own style, their own API, their own restrictions. WCF unifies those under a common and highly configurable programming model
marc_s
+3  A: 

@acidzombie24, to counter your comment to Ryan's answer:

WCF is NOT a remote function call - not at all. Quite the contrary!

WCF is a message based communication system - your clients will have a proxy that has the same method as the server. When you call such a function on the client proxy, what the WCF runtime does is wrap up those method parameters, the method name, and some headers into a serialized message and it sends that to the server.

There is no constant connection like a remoting protocol or a database connection open at all times, between the client and the server. The client packages up a message and send it off. The transport media between client and server could even be SMTP (e-mail) !

Once the server receives the message, the WCF runtime will instantiate an instance of your service class to handle that request. The appropriate method on that service class will be called, the parameters are passed in, the service does its work, and the response is generated. The response then travels back the same way - serialized message across a transport media - to the client.

WCF is a general-purpose, message-based communication system to enable you to create distributed systems - you have a bunch of services somewhere on your servers, which offer up to perform certain functions on the client's behalf, when they call. WCF is something like web services - only much more than that. It's also message queueing (using Microsoft's MSMQ product), net/TCP communication and a lot more. And it's much more extensible than any communication API before.

marc_s
>There is no constant connection>the WCF runtime will instantiate an instance of your service class to handle that requestSo if i have members in the class it will be serialize and sent off with the rest of the parameters. I'll assume the default and most common transport media is using TCP sockets. Is there a http like keep-alive? it sounds like if i have to send 2 or more messages after eachother (and can not be made as 1 message) it can get slow?
acidzombie24
You are correct that it is not a RPC system. Great point that I did not cover very specifcally. There are some dual bindings which provide things not easily available elsewhere, such as Peer-2-Peer, and Dual SOAP bindings. It is also greatly extensible as you pointed out allowing you to even create your own binding using any method you would like.
Ryan from Denver
@acidzombie24: WCF supports HTTP, NetTCP, MSMQ, UDP, SMTP and a plethora of other transports - and you can create your own, too. No, there's no "keep alive" - that's totally against the whole idea: the idea is, you just call your service and it handles the request. There's no state, there's no constant connection, there's no "keep alive" or "check if it's alive" function - just pure message passing.
marc_s
Interesting. The only thing that gets me now is the return value :|. Doesnt that have to wait for a response before returning? if its smtp couldnt that take hours (instead of perhaps a fail/exception)? wouldnt code be locked up?
acidzombie24
@acidzombie24: well, if you're using SMTP, you'll probably want either asynchronous calls (don't wait 'til answer is back), or one-way calls (just sending - not waiting for a response)
marc_s
interesting, i havent used it before so i didnt know you can send and not have a response. cool. You fully answered my question.
acidzombie24
+1  A: 
  • WCF is the replacement for ASMX Web Services and for .NET Remoting
  • WCF is a message-based platform for communications
  • WCF is the recommended Microsoft platform for building and consuming web services of all kinds
  • WCF is not limited to HTTP/HTTPS or to hosting in IIS. One can host a WCF service in any process
  • The WCF Developer Center is a good place to start, or maybe in the Beginner guide
John Saunders