Understand WCF and its communication again (attach a Cheng experience)

Source: Internet
Author: User

I. Overview

  Windows Communication Foundation (WCF) is a set of data communication application development interfaces developed by Microsoft, which can be translated as a Windows communication interface and it is. NET Framework is part of the. Introduced by the. NET Framework 3.0.

  The ultimate goal of WCF is to send and receive messages between customers and services through a process or a different system, through a local network, or over the Internet.

  WCF incorporates the capabilities of Web services,. NET Remoting, Message Queuing, and enterprise services and integrates them in Visual Studio.

  WCF is dedicated to service-oriented development.

second, based on Application development and service-oriented development of ASP.

On the basis of in ASP. NET application development, we access the application server from the client's browser, then connect to the database server through the database connection in the application server, read or manipulate the data, and sometimes one more file server.

As you can see, basically all applications are placed on a single server, but for one, it is difficult for one server to support all applications due to business needs (such as interacting with external systems). Let's look at the following figure:

Client Access server using browser A, server A is deployed in Servers B, C, D ... for business needs with a variety of other applications. And then communicate with each other through WCF technology, visit each other ... However, the benefits of service-oriented are not only here, but it also provides interoperability for different operating systems in different languages.

Since this article is not an article about SOA, interested students can see: SOA;

I. Overview (WCF communication)

  WCF is able to build a cross-platform secure, trustworthy, transactional solution that is a webservice,.net remoting,enterprise service,wse,msmq, with a classic contrast chart as follows:

Second, Introduction to "A", "B", "C" in WCF

We first look at an example of life, one day, the company's leadership let you send a contract document, the process of sending documents you can choose the mode of transportation for "taxi", "bus", "Subway", of course, the cost is based on the invoice to reimburse, to the other company after you have to find a manager, and a copy of receipt of the Contract Documents and related documents.

To accomplish this task we perform the following major steps:

  (1) We first need to know the address of the other company, which leads to "A" in WCF.

  A (address): The English language is understood as "addresses", in the computer is identified by a URI unique address, through which we can find the WCF service we want to invoke.

  A resolved: Where to locate the WCF Service?

  (2) We also have to choose our mode of transportation, each way of transportation to achieve different results. such as: Taxi cost more expensive, but the process comfortable, time depends on the road conditions. Buses are the cheapest, and multiple lines can be selected. The subway is the most convenient, but occasionally very crowded, generally no seat, etc., lead to the "B" in WCF.

  B (binding): English is understood as "bundle, bind," and the binding implements all the underlying details of the client and service communication. Such as: What kind of encoding do we use when we transfer to the client and server, XML? Text? Binary? ... What kind of transport protocol is used for transmission, TCP? Http? And what mechanisms are used to address security issues, SSL? Encryption? ...

  B solved: How to communicate with service?

  (3) What can we do after we get to the other company? I. Send the contract, II. take the receipt. We can't ask the other company to give us something else that leads to the "C" in WCF.

  C (contract): English is understood as "contract", what is the contract? Tell us what we can do and what we can't do. The primary role of contract is to expose all the valid methods provided by a WCF service. Contract actually transforms each method into a corresponding message.

  C Solved: What functionalities does the Service provide?

Third, Endpoint (end point)

  WCF implements the communication of the various applications of the network system. The communication for each application is implemented as an " endpoint (Endpoint)" . A, B, and C are part of the endpoint in the actual example above, and he is the portal for communication calls between servers.

Iv. Communication between applications

we have spoken in the second and third A, B, C and endpoint, now officially enter the communication between applications. Let's just take the process of sending the contract for example.

Employees A There is a note in the hand, marked with: address, binding, contract ..... The partner also has a note that marks the same content and has been waiting for employee a to appear. Partner A will sign a contract receipt only if the content on the note is the same.

when we homestay WCF services, we have to define one or more endpoints, and then the serivce side handles requests from the client by listening to those endpoints. Since applications are communicated by endpoint, we must also define endpoints on the client side.

Communication is only possible when the client exactly matches the endpoint of the service.

as shown: only Endpointa in A, B, C and ENDPOINTB in A, B, c exactly match to communicate. Endpointe and Endpointd are the same.

at this point, Understanding WCF again and its communication End it!

Practice Training:

1. The first WCF program (completed), refer to the blog: http://www.cnblogs.com/iamlilinfeng/archive/2012/09/25/2700049.html

2, a WCF programming experience:

WCF publish, native normal, server error, information as follows:

Workaround:

<serviceBehaviors>

<behavior>

<!--to avoid leaking metadata information, set the following values to false before deployment

<servicemetadata httpgetenabled= "true" httpsgetenabled= "true"/>

<!--to receive the fault exception details for debugging, set the following value to True. Set to false before deployment to avoid leaking exception information--

<servicedebug includeexceptiondetailinfaults= "true"/>

</behavior>

</serviceBehaviors>

Httpsgetenabled= "true"/changed to: Httpsgetenabled= "false"/OK.

Perfect Solution !

Understand WCF and its communication again (attach a Cheng experience)

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.