Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusion about WCF Channels

I am confused about the Proxy and Channels. According to my reading, WCF client is using a proxy which pass the message through a chain of channels. Every Channel is responsible of certain task, for example one channel is encoding the message and another Channel is encrypting it.

My confusion begins when I saw the following code

  • When proxy.MyMethod() is called, it actually called the whole chain of channels?

  • The author used method called CreateChannel and named the identifier proxy. So in WCF architecture Proxy is just a spacial high level channel, it is not a stand alone architecture element?

    Binding binding = new NetTcpBinding();  
    EndpointAddress address = new EndpointAddress("net.tcp://localhost:8000");  
    IMyContract proxy = ChannelFactory<IMyContract>.CreateChannel(binding,address);  
    using(proxy as IDisposable)  
    {  
        proxy.MyMethod();  
    }  
    
like image 246
Costa Avatar asked Mar 04 '13 12:03

Costa


1 Answers

In WCF you have 3 main component - Contract, Adress and Binding. The channel is a pipe, which is building according to these three parts.

enter image description here

The aim of the channel is to modify the message into format, that is understood for both - client and server, and to organize it's proper transport. The transport and protocol channels are used for this. To make this process easier, we use bindings. Each binding consists of elements, which are representing some channel in channel stack.

So, each time when you call you method, it forms the message according to your DataContract, and passes it throught the whole chain of channels. Each channel modifies your message. The prosses looks like this

enter image description here

A WCF proxy is really just a level of abstraction. It is an in-process representative of an out-of-process service. You can imagine it as an object, generated and properly configured according to your binding elements and your dataContract, which allows your client-side and server-side to understand each other.

like image 187
Alex Avatar answered Sep 22 '22 04:09

Alex