As a fast-paced series of WCF, this article only introduces some practical knowledge commonly used in project development.
To learn about wcf, I 'd like to take a look at several terms. There is an ABC concept in wcf, that is
First, "A" is the address, that is, to tell someone where I am using wcf.
Second, "B" is binding, that is, to tell others how to come.
Third: "C" is a contract: it is to tell others what I have in wcf.
Three bindings are commonly used in project development:
First: wsHttpBinding. This binding can be considered as an enhanced version of webservice WSE. It is designed for interaction between heterogeneous systems (such as java ).
Second, netTcpBinding, which can be considered as an enhanced version of remoting, is designed for. net program interaction on different machines,
Third: netMsmqBinding, which can be considered as an enhanced version of msmq, is designed to interact with. net programs of different machines in an offline environment to ensure that information is not lost.
The following describes the actual code usage of the first two types of binding.
WsHttpBinding:
Step 1: create a new class library and create the IFly and People files respectively, that is, complete the "C" work in wcf,
Step 2: Since "C" has come out, she must have the environment that carries her, that is, the so-called "host ". Here we use the console to carry.
Create a console program.
Step 3: The Service is currently in the pre-enabled status. To make wcf more flexible and easy to control, you need to write the relevant configuration into the config.
Create a new config file in the console class library, and then run the console program to start it. The Code diagram is as follows: www.2cto.com
Finally, wcf is enabled and the address is being monitored. Then, we create a Client program for the console, and right-click the reference in reference to add a service reference.
Click "OK" and the reference is complete. Next, it is as simple as calling a local program to call wcf. Haha.
NetTcpBinding:
If you understand how to use wsHttpBinding, changing it to netTcpBinding will be easy. Because you only need to modify it in two places.
1. Modify the endpoint address in the configuration file.
Second, update the "service reference" of the client, and run it.
Haha: now we know the intuition difference between wsHttpBinding and netTcpBinding.
NetMsmqBinding:
If you know the above two types of binding, try msmqbinding. This is what I will share the next day in the series.
Author huangxincheng520