代码改变世界

What is WCF for me?

2011-03-16 17:07  Aga.J  阅读(451)  评论(0编辑  收藏  举报

   Recently, one of my project required me to handle WCF (Windows Communication Foundation) to solve some communication problem. So I began to study WCF three days ago.

   First of all, I need to find some resources about WCF. Yeah, MSDN is good place to study my investigation on WCF. Here is the web site: http://msdn.microsoft.com/en-us/library/dd456779.aspx. You can clearly learn the whole knowledge about WCF in MSDN. It takes you go throught the process to build a simple WCF application. It explains all concept and all feature details about WCF. Simply speaking, a whole WCF application is composed of Contract, Contract implement(service), host process, Client. We need to design our service contract first. It is realy important because the contract is closed to your business service. Next , we need to implement the contract and configure our services . We can do some change on communication protocol , message encoding and other protocols about security while we are configuring our services. After finishing this, we run our service in the host process(we can host services in many different types of host in WCF). Keeping the service running,we can add web reference in our client application. Once you successfully add the reference, VS will generate all thing about WCF client to you. At last, you simply initiate client proxy and invoke the service you want in your client application. These two pictures below can help you to understand the core of WCF.

                   

    I just simply describe something about WCF. If you need more detail, please go to the MSDN. Forgive my idleness.

    After I finished reading articles in MSDN, I feel interested in how WCF work in detail. So I find some artical about this and try to analyse a simple WCF project created by myself. A last I find a picture that can explaint a little bit of the detail work the WCF does. Here it is:

                        

      It's not easily to see the details clearly. So I redraw it using Chinese.

    ok, I recognize that I still can not know details about WCF through this picture. I want to know exactly how WCF does, such as how they translate the interface and class into metadata , how they create the SOAP file, how they use the SOAP file, how they create the client, most importantly , how they communicate through network.