5-day speed of the wcf series -- Use of binding on the first day (1)

Source: Internet
Author: User

 

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.