Chapter 3 address (Comprehensive Analysis of WCF 3)

Source: Internet
Author: User
Tags in domain msmq
WCF Gu mingyu is a basic framework (F, Foundation) for Communication (C, Communication) on the Windows platform. The endpoint is the most core object of WCF because it carries all the communication functions. The service is released through the corresponding endpoint, and the client calls the service through the endpoint that matches it. The endpoint consists of three elements: Address, binding, and contract ABC. Address, which is one of the three elements of an ending point, is not only used for locating services in WCF-based communication, but also provides additional addressing information. In addition, the endpoint is related to security because it contains the Service identity information used for service authentication. Directory 2.1 unified resource ID (URI) 2.1.1 HTTP/HTTPS 2.1.2 net. TCP 2.1.3 net. pipe 2.1.4 net. MSMQ 2.2 endpointaddress 2.2.1 server endpoint address 2.2.2 client endpoint address 2.2.3 Address Header 2.3 Port Sharing 2.3.1 Port Sharing significance 2.3.2 HTTP | HTTPS Port Sharing 2.3.3 TCP port sharing 2.4 logical address and physical address 2.4.1 service role 2.4.2 listener address and listener mode 2.4.3 clientviabehavior 2.4.4 instance Demonstration: routing messages through tcptrace (s205, s206) 2.5 request listener and message delivery 2.5.1 connection request listener 2.5.2 unified message distribution Resource (URI) the full name of URI is uniform resource identifier, which uniquely identifies Network resources, as well as the resource location and access method (network protocol used for resource access ). The Uri has the following structure: transmission protocol: // [host name | Domain Name | IP address]: [Optional port]/[Resource path] 2.1.1 HTTP/httpshttp is called Hypertext Transfer Protocol (Hypertext Transfer Protocol) and is an application layer protocol established on a TCP/IP cluster. HTTP provides a simple request-recovery (request-reply) message transmission method.
HTTP is stateless, and each HTTP request is independent of each other.
HTTP is connectionless. HTTP-based data transmission requires no prior connection. HTTPS is called Hypertext Transfer Protocol over Secure Socket Layer (Secure Hypertext Transfer Protocol ), it uses SSL (Secure Socket Layer) HTTP, while SSL is a data encryption protocol, many websites with high security requirements adopt HTTPS. WCF implements HTTP-based transmission security through HTTPS ). The HTTP and HTTPS Uris use HTTP and HTTPS as the prefix (Scheme) of the transmission protocol respectively. The default ports are 80 and 443 respectively. Therefore, the following two sets of URIs are equivalent. Http://artech.com: 80/myservices/calculatorservice. SVC
Https://artech.com: 443/myservices/calculatorservice. SVC

Http://artech.com/myservices/calculatorservice.svc
Https://artech.com/myservices/calculatorservice.svc
2.1.2 net. tcptcp is fully called the Transport Control Protocol (Transport Control Protocol) and is at the core of the entire TCP/IP cluster. From the perspective of the entire protocol hierarchy, It is located under the application layer and above the network layer (IP protocol. Compared with HTTP, TCP is specific as follows: TCP is a connection-based transmission protocol. Before data transmission starts, it creates a connection through three "handshakes" between the client and the server; after the transmission ends, the connection is terminated by 4 "handshakes.
TCP is stateful. Because data is transmitted in a certain connection, the status of each data transmission can be maintained.
TCP supports full-duplex (Duplex) communication. Once the connection is successfully created, data can be transmitted simultaneously in both directions.
TCP supports reliable messaging. The data transmission provided by the IP protocol is unreliable, and the reliable data transmission can only be ensured through TCP. WCF supports TCP-based transmission through nettcpbinding. For a TCP Uri, the Transport Protocol prefix is net. TCP ://. The default port of Net. TCP is 808. The following two Uris are completely equivalent. Net. TCP: // artech.com: 808/myservices/calculatorservice
Net. TCP: // artech.com/myservices/calculatorservice 2.1.3 net. Pipe Named Pipe (Named Pipes) is a standard implementation method for Implementing Inter Process Communication (IPC) on Windows and UNIX systems. Although the named pipe itself can implement cross-machine communication, WCF only uses the Named Pipe for cross-process communication on the same machine, therefore, the host name based on the URI of the named pipeline | the IP address must be the machine name, localhost, or 127.0.0.1 of the local machine. The following is a typical net. pipe urinet. pipe: // 127.0.0.1/myservices/calculatorservice2.1.4 net. message Queue (MSMQ) is Microsoft's pioneering attempt in the message service field. Because message queues adopt special communication mechanisms, it is of great significance to improve and improve scalability and high availability of the system. The following two types of message queues are available. Public Message Queue: The name of a common queue is registered in the ad domain. Therefore, you do not need to specify the machine name of the queue to access the queue. When a common queue is transferred from one machine to another, the applications accessing the queue can remain unchanged. Common queues can also provide Windows Authentication Based on domain accounts. Therefore, common queues are usually used for officially published applications.
Private Message Queue: because a common queue needs to be registered in the ad domain, it can only be used in domain mode. In work group mode, only private queues can be used. To access a private queue, you must specify the path containing the name of the machine where the queue is located.
In addition to common queues used to store business data messages, there are also management queues for storing confirmed messages, log queues for storing copied messages, reply queues for storing reply messages, and dead message queues for storing dead messages. In addition to physical queues based on independent files, there are also sub-queues attached to physical queues. In WCF, message queue-based Uris have the net. MSMQ prefix. Private represents a private queue between the host name and queue name, while URI of a public queue indicates that the queue type is not required. The following two net. MSMQ addresses are provided. Net. MSMQ: // artech.com/myservices (Public Queue)
Net. MSMQ: // artech.com/private/myservices (Private Queue) 2.2 endpointaddress the endpoint is represented by the system. servicemodel. description. serviceendpoint type in the WCF application programming interface. The three core attribute sub-tables represent the three elements of the endpoint address, binding, and contract. 2.2.1 server endpoint address 2.2.2 client endpoint address 2.2.3 address Baotou 2.3 Port Sharing for some common network services, they all have a well-known port number matching: the TCP port of the FTP service is 21, the TCP port of the Telnet service is 23, and the client usually does not care about the port used. You only need to ensure that the port is unique on the local machine. This is the temporary port of preschool education. The temporary port is usually 1024 ~ Port Sharing between 5000 and: What is the significance of Port Sharing in a general network environment? To avoid network attacks as much as possible, most ports are blocked through the firewall, only the ports used by common network services are retained, or only a small number of ports are reserved for a certain type of applications. All in all, we cannot ensure that each cross-firewall communication application has a unique port. They can only share a few active ports. Within the Intranet, in order to ensure that the network applications deployed on other computers in the LAN can communicate with the Local Computer normally, a few available ports are usually reserved in the local firewall. Intranet hosts can use these reserved ports to communicate with each other through the corresponding transmission protocol. For firewalls between the Internet and the local network, only port 80 | 443 is reserved to ensure that the Network Communication Based on HTTP | HTTPS is normal. Therefore, whether based on Intranet or internet, Port Sharing has practical significance. 2.3.2 HTTP | HTTPS Port Sharing 2.3.3 TCP port sharing net. in terms of functions, the TCP Port Sharing Service. the TCP Port Sharing Service implements HTTP. sys has the same function, that is, request monitoring and distribution. However, HTTP. sys runs in kernel mode, while net. TCP port sharing service runs in user mode) under TCP port sharing and nettcpbinding configure portsharingenabled = "true" 2.4 logical address and physical address in binding under the nettcpbinding node to represent the endpoint address type. The URI attribute of the endpointaddress object only represents the service logical Address. The physical address we call is the listening address for the server. For the customer, yilai is the destination address of the message actually sent. By default, physical addresses and logical addresses are unified. However, due to the limitations of the network environment, we need to separate logical addresses from physical addresses. 2.4.1 server role 2.4.2 the listening address and listening mode listenuri can be configured to indicate the configuration node (Services/service/Endpoint) of the server end point, which has the listenuri attribute. If you do not set the listenuri display, the modified attribute value has the same URI as the endpoint address. That is to say, the logical and physical addresses of the server end point are not separated by default. Listenurimode when the listenuri attribute of the endpoint is set, it does not mean that the endpoint must use this URI for request listening. The final listening address also has another decisive factor, namely the listening mode. The two enumerations of listenurimode indicate two methods to determine the final listening address. Explicit indicates that the URI set by the listenuri attribute of the endpoint is strictly used as the final listening address, while unique ensures that the final listening address is unique according to different listenuri policies. WCF uses the following policy to ensure the uniqueness of the listening address:
If TCP is used as the transmission protocol and Port Sharing is not used, an unused port is selected as the port of the final listening address to ensure the uniqueness of the address.
If TCP is used as the transmission protocol and Port Sharing is not used, a guid is added as the suffix to ensure the uniqueness of the address.
For non-TCP transmission protocols, a guid is added as the suffix to ensure the uniqueness of the address. 2.4.3 The clientviabehavior Action client separates the logical address from the physical address through an endpoint action. Behavior is a very important concept in WCF and the most important way to extend it. A contract is a consensus between the server and the client on a certain aspect. It is a bilateral protocol, and the behavior is a way for the client or the server to implement a certain function locally, is a unilateral action. Contract behaviors and operation behaviors are defined as attributes and applied to the operation methods of contract interfaces/classes, contract interfaces, and service types respectively, the endpoint behavior can only be applied to the server or client node through configuration. As for service behavior, you can either adopt the feature declarative application method or the configured application method. Service Behavior and Endpoint behavior are defined in behaviors/servicebehaviors and behavior/endpointbehaviors respectively.
The configuration node services/service/endpoint of the service configuration node services and endpoints. There is a behaviorconfiguration on the endpoint node, which is used to set the service behavior and Endpoint behavior. Wcf4.0 also supports default behavior configuration 2.4.4 instance Demonstration: Using tcptrace for message routing (s205, s206) 2.5 request listening and message delivery 2.5.1 connection request listening 2.5.2 message distribution
Comprehensive Analysis of WCF
Chapter 2 address

Chapter 3 address (Comprehensive Analysis of WCF 3)

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.