Learn WCF (13) with me -- Summary of the WCF series, wcf13

Source: Internet
Author: User

Learn WCF (13) with me -- Summary of the WCF series, wcf13
Introduction

WCF is Microsoft's framework for implementing SOA. It inherits and extends multiple distributed technologies before micro-emulsion, including Enterprise Service,. NET Remoting, XML Web Service, and MSMQ. The reason for the launch of WCF is that Microsoft wants to integrate different distributed technologies to provide a unified programming model, which is definitely a good thing for developers. In the past two months, I have successively written a series of articles on WCF. These articles are just a learning process and notes for me to learn about the content of WCF, we hope to record and summarize this blog post. This series does not provide in-depth analysis on the WCF mechanism, but only explains the functions and implementations supported by WCF. For more in-depth understanding, I believe that, only when problems are encountered and solved in the project can we have a deeper understanding. This series of articles only gives you a comprehensive understanding of WCF. The following is an index of this series of articles, hoping to help you collect the index and help me index myself.

[Article 1st] Learn WCF with me (1) -- MSMQ Message Queue

MSMQ, Microsoft Message Queue-Microsoft Message Queue, one of Microsoft's distributed technologies. The working principle is: the client sends a message to a message queue, and the service extracts the message from the message queue for processing. The coupling between the client and the service is isolated by means of message queue. The most obvious advantage is the asynchronous and offline functions. The disadvantage is: because the client does not directly send messages to the service for processing, but sends messages to the message queue, the response may be delayed when a large number of requests require real-time service interaction between the client.

[Article 2nd] Learning WCF with me (2) -- using. NET Remoting technology to develop distributed applications

. NET Remoting is another Distributed Technology of Microsoft. The internal implementation of WCF draws on the implementation of this technology .. NET Remoting can communicate across application domains. Its disadvantage is that it does not support offline functions and is only applicable to. NET platform programs. Shows how it works:

[Article 3rd] Learning WCF with me (3) -- using Web Services to develop distributed applications

XML Web Service is another Distributed Technology of Microsoft. It has the advantages of cross-platform, cross-firewall and self-description, such as MSMQ and. NET Remoting cannot be used across platforms because it transmits binary data, while XML Web Service transfers XML-based text files. Its disadvantage is its efficiency and security, and it is not suitable for LAN applications. Therefore, in general, the LAN can use MSMQ and. NET Remoting technologies, while Internet-based applications use XML Web Services. The implementation principle is shown in:

[Article 4] Learning WCF with me (4) -- The First WCF Program

As mentioned before ,. NET Remoting, XML Web Service, and other technologies are inherited and extended. Therefore, using WCF can be used for both Lan-based and Internet-based distributed applications. The most important concept of WCF is endpoints. Service providers publish services to service consumers through one or more endpoints. The endpoint consists of the address, binding, and contract.

These three elements play the following roles in WCF communication:

  • Address): The address identifies the location of the service, provides the secondary information of addressing, and identifies the real identity of the service. Address solvedWhere the WCF service?.
  • Binding): Binding implements all the details of communication, including network transmission, message encoding, and other functions to implement certain functions, such as secure, reliable transmission, and transaction. WCF has a series of system-defined bindings, such as BasicHttpBinding, WsHttpBinding, and NetTcpBinding. Binding solves How to Communicate with Service? .
  • Contract)A contract is an abstraction of service operations and a definition of the message interaction mode and message structure. A WCF contract can be divided into two types: service operation description and data description. Service Contract is a description of Service operations, and the latter includes three contracts: Data Contract and Message Contract) and Fault Contract ). Contract solves What function does the Service Provide? .

The subsequent WCF articles will introduce the extensions of these three elements.

[Article 5] Learning WCF with me (5) -- In-depth analysis of service contracts [Part 1]

To define a WCF Service, the first step is to define a service contract. This blog article mainly introduces how to implement Operation overloading in WCF. The main implementation logic is to define aliases for the same method, so that the operation tag in the generated WSDL is different.

[Article 6] Learning WCF with me (6) -- In-depth analysis of service contracts [Part 2]

If the contract inheritance relationship is defined in the service, the proxy class generated by the client does not generate a contract structure with the inheritance relationship. The idea to solve this problem is to customize the proxy class, make it have the same inheritance structure as in the service contract.

[Article 7] Learn about WCF with me (7) -- detailed explanation of WCF data contract and serialization

A Data contract is a custom type to be transferred between a service and a client. Some basic types such as String and int can be serialized, therefore, by default, WCF can serialize and transmit these types, but custom classes, struct, and Other types are not supported by default, in WCF, The DataMemberAttribute feature is that custom types can be serialized for transmission and deserialized into objects in the service for data processing. In WCF, the default serializer is the DataContractSerializer class.

[Article 8] study with me on WCF (8) -- Session and instance Management in WCF

The management of WCF Service instances draws on the Implementation of. NET Remoting technology. There are also three activation methods for service instances: monotonous service, session service, and Singleton service.

  • Percall): Assign a new service instance to each client request. Similar to SingleCall mode in. NET Remoting
  • Session Service (Persession): Share a service instance for each client request during a session, similar to the client activation mode in. NET Remoting.
  • Singleton): All client requests share the same service instance, similar to the Singleton mode of. NET Remoting. However, you must note that when Host is performed for a service type, the corresponding service instance is created, all subsequent service calls are processed by this service instance.

In WCF, the default Service Activation Method is PerSession, but not all Bingding supports Session. For example, BasicHttpBinding does not support Session. You can also disable ServiceContract in the following ways.

[Article 9] Learn about WCF (9) with me -- Implementation of the WCF callback operation

In WCF, in addition to the classic request/response mode, it also supports unidirectional operations and bidirectional callback operation modes, as well as stream operations. This article describes how to implement callback operations in WCF.

In WCF, not all bindings support callback. Only bindings with Bidirectional capabilities can be used for callback. For example, HTTP is essentially unrelated to the connection, so it cannot be used for callback. Therefore, we cannot use callback based on basicHttpBinding and wsHttpBinding binding. WCF provides callback support for NetTcpBinding and NetNamedPipeBinding, because both TCP and IPC protocols support two-way communication. To enable Http to support callback, WCF provides WsDualHttpBinding binding. It actually sets two Http channels: one for calling from the client to the service, and the other for calling from the service to the client.

Callback is implemented through a callback contract. A callback contract is part of a service contract. A service contract can only contain One callback contract. Once the callback contract is defined, the client needs to implement the callback contract. In WCF, The CallbackContract attribute of ServiceContract can be used to define the callback contract.

[Article 10] Learning WCF with me (10) -- transaction processing in WCF

WCF supports transaction transmission. The transaction transmission mode is determined by the bound transaction flow attribute (TransactionFlow attribute) and the transaction flow option (TransactionFlowOption) in the operation contract) and the transaction range attribute (TransactionScopeRequired) in the operational behavior characteristics are jointly determined. Four transmission modes supported by WCF transactions are Client/Service, Client, Service, and None. Is the recommended setting for the four propagation modes.

[Article 11th] Learn about WCF (11) with me -- detailed explanation of the queue service in WCF

Since WCF inherits and extends various distributed technologies, it naturally supports offline functions. This article describes how to support and implement the queue service in WCF. The implementation method is similar to the implementation method of MSMQ, but WCF provides new API support for queue services, mainly through MsmqIntegrationBinding. Its communication mechanism is shown in:

[Article 12th] Join me in learning WCF (12) -- getting started with the Rest service in WCF

Roy Thomas Fielding proposed the concept of Rest in his doctoral thesis ("architecture style and Network Software System Design. A Rest service abstracts a service as a resource. Each resource has a unique Uniform Resource Identifier (URI). We no longer use the call operation to interact with the service, it is done through the unified interface of HTTP standard verbs (GET, POST, PUT, and DELETE .. After NET 3.0, Microsoft provided new APIs to support the Rest service in WCF. These classes include the WebHttpBinding class, WebGetAttribute, WebInvokeAttribute feature, and WebServiceHost class. The implementation method is similar to that of the previous WCF program, but the new API is used to define the service.

Conclusion:

At this point, the WCF series has come to an end. By studying the WCF technology system, I have a comprehensive understanding of the WCF technology, after a deep understanding, you need to accumulate and practice in the project. I hope this series can help some beginners.

 

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.