Search code examples
.netwcf

What is WCF? and what can it do?


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


Solution

  • @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.