Original: WCF Series 5-day crash-the first day of binding use (1)
As a WCF Crash series, just introduce some of the practical facts that are commonly used in project development.
Learn about WCF, or just a few of these terms. There is an ABC concept in WCF, which is
The first: "A" is the address, which is to tell others where I am WCF.
Second: "B" is a binding, that is, to tell others should take what way to come.
Third: "C" is a contract: just tell someone what I have here in WCF.
Three types of bindings commonly used in project development:
First: Wshttpbinding, this binding can be thought of as WebService's enhanced WSE, designed to be used for heterogeneous system interactions (such as Java).
Second: nettcpbinding, this binding can be thought of as remoting's enhanced version, designed to be used for different machine. NET program interactions,
Third: netMsmqBinding, this binding can be considered as an enhanced version of MSMQ, designed to interact with the. NET programs of different machines in an offline environment to ensure that the information is not lost.
The following is the actual code for the first two types of binding application.
Wshttpbinding:
The first step: Create a new class library to create ifly and people files, that is, to complete the "C" work in WCF,
The second step: since "C" has come out, then she must have to carry her environment, that is, the so-called "host." This is carried by the console.
Create a new console program.
The third step: Now the service is in a pre-open state, in order to make WCF more flexible, more easy to control, it is necessary to write the relevant configuration into config.
Create a new config file in the Console class library, and finally run the console program to start formally. The code map is as follows:
Finally: WCF is on, monitoring the address, then we are building a console client program, "right-click" in the reference to add a service reference.
After clicking OK, the reference is complete, and then we call WCF as simple as calling the local program. Ha ha.
NetTcpBinding:
If you understand how to use wshttpbinding, then change into nettcpbinding will be easy. Because only two places can be modified.
First: Modify the endpoint address in the configuration file.
Second: Update the "service reference" under the client, and then run the look down.
Haha: now know the Wshttpbinding and nettcpbinding intuition difference.
NetMsmqBinding:
If you know the two types of binding above, try the Msmqbinding bar, which is what I want to share in the second day of the series.
WCF Series 5-day crash-the first day of binding use (1)