WCF distributed development Step-by-step for Win (9): WCF Service instance activation type programming and development

Source: Internet
Author: User

There are three ways to activate the. Net Remoting: Singleton mode, SingleCall mode, client activation, and WCF service instance activation types include three ways: monotonous service (call service), session service (sessionful Service), a single example (Singleton services). What is the connection between them? Advantages and disadvantages of WCF service activation types, and how to programmatically develop and set up service instances within a project. The full text is divided into 5 parts, first one introduces the monotonous service (call service), Session services (Sessionful service), a single example service (Singleton service) related concepts, advantages and disadvantages, followed by the sample Code Analysis and Explanation section, Finally, the summary part of the full text. The structure is as follows: "1" monotonous service (call service) "2" Session service (Sessionful service) "3" single example service (Singleton service) "4" Sample Code Analysis "5" summary. Finally, the code for this article will be uploaded.

"Introduction":

Prerequisite knowledge in WCF distributed development (2):. NET Remoting in this article I have covered the concept of net remoting, which also includes the mode of activation of NET Remoting: Singleton mode, SingleCall mode, How the client is activated. In fact, the way WCF services are activated is similar to this. The service activation method is also a clear example of WCF drawing on net Remoting. NET Remoting related concepts You can review the prerequisites for WCF Distributed Development (2):. NET Remoting this article. Here's a detailed introduction to the WCF Service activation type-related knowledge points. The first thing to introduce is monotonous service.

WCF supports the three types of instance activation:

1> (Per-call Service): Each client request assigns a new service instance. Similar to net remoting SingleCall mode;

2>. Session Services (Sessionful service): Assigns a service instance to each client connection. The client activation mode similar to NET remoting;

3> (Singleton Service): All clients share a single service instance for all connection and activation objects. A singleton pattern similar to net Remoting.

The service activation mode here is defined by the context pattern of the service we define InstanceContextMode

property to be configured with the following code:

public enum InstanceContextMode
{
     PerSession,
     PerCall,
     Single
}

"1" Monotonous service (call service):

"1.1" Basic concepts

Monotonic Service (Per-call services): Each client request assigns a new service instance. The life cycle of a service instance is tightly limited to the beginning and end of a call. Each request from the client generates a new service instance to respond to the call. A singlecall pattern similar to net Remoting. The following steps are performed:

1. The client invokes the proxy, and the agent forwards the call to the service.

2. WCF creates a service instance and then invokes the method of the service instance.

3. When the method call returns, WCF invokes the IDisposable.Dispose () method if the object implements the IDisposable interface.

4. The client invokes the proxy, and the agent forwards the call to the service.

5. WCF creates an object and then calls the method of the object.

An instantiated model diagram of a monotone service:

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.