WCF Reading Notes (3)

Source: Internet
Author: User

Bind

Basic binding: Provided by the BasicHttpBinding class

TCP binding: Provided by the NetTcpBinding class

There are several other uncommon

Endpoint

Services are related to addresses, bindings, and contracts. The address defines the service location, the binding defines the service communication mode, and the contract defines the service content. The summary point is the mixed finished products of the address, contract and binding.

◆ The WCF summary point is the real interface, because it contains all the information required for an object's interface. In WCF, address and binding are not inherent and need to be configured.

Reliability: The biggest difference between WCF and other service-oriented technologies lies in the transmission reliability and message reliability. Transmission reliability provides point-to-point transmission at the network packet layer to ensure correct data packet sequence. Message reliability is responsible for processing the reliability of the message layer. It has nothing to do with the number of data packets that transmit messages. Message reliability provides end-to-end transmission to ensure the order of messages is correct.

The WCF Service must depend on a running process (host). The service host specifies a host for the service.

WCF is a message-based communication framework that uses end-point-based communication methods.

Endpoint = ABC (Address, Binding, Contract), that is, Address, Binding, and Contract

Address: determines the service location and solves the service addressing problem.

Binding: implements all the details of communication, including network transmission, message encoding, and other operations to implement certain functions to process messages.

Contract: the abstraction of service operations. It also defines the message exchange mode and message structure.

Loose coupling is a basic feature of SOA. The loose coupling between the client and the server in a WCF application is reflected in the fact that the client only needs to understand the basic description of the WCF Service, rather than the specific implementation details, you can call the service normally.

WCF: a basic framework for communication on the Windows platform.

Endpoints (addresses, bindings, and contracts), Real interfaces, including everything required for interaction.

The communication function of the endpoint: the service provider publishes an endpoint to a potential service consumer through one or more endpoints, and the service consumer consumes the service by matching the endpoint.

The role of addresses in Communication

Locate the service location? (Whether the address of the service provider or the address of the service consumer) (corresponding to the URI attribute of the endpoint)

Provide auxiliary information for Addressing ???? (Corresponding to the Headers attribute of the endpoint)

The real identity of the Service ???? (Corresponding to the Identity attribute of the endpoint)

The three addresses correspond to the three attributes of the endpoints.

URI

It may be the real physical address or logical address of the deployed service.

URI transmission protocol:

HTTP \ TCP \ ICP (transmission protocol used for communication between different processes on the same machine) \ MSMQ

Physical address: the address where the service is actually deployed

Logical Address: The address we specify. (in some cases, the actual service address is a private address or a dynamic address. In this case, we must specify the service address as a fixed common address, when message exchange is required, messages are sent to the real target address through some routing mechanisms)

AddressHeader

The service provider and the service consumer communicate with each other through SOAP-based messages (REST/POX), while soap is a self-describing entity that consists of the message Body) (service content) and several headers (storage control information.

When the physical address is different from the logical address, it is often necessary to manually send, receive, process, and forward messages. The AddressHeader of the endpoint is designed for this purpose. It can be used on the server to filter messages based on the endpoint address.

EndpointIdentity

Authentication or identification in applications and distributed application environments. (You do not need to know more)

How do I specify an address?

First, on the server side: if it is a local host, you can add endpoints (one or more) by programming to specify the address, or you can add endpoints to specify the address through configuration, note that, in general, the listening address and Endpoint address are unified. When the physical address and logical address of the endpoint are inconsistent, you must specify the listening address different from the endpoint address. If you are using IIS, the service address is the. svc file, and you do not need to configure the endpoint address.

When the address is given in the relative address mode, because the matching relationship between the base address and the local address is determined based on the transport protocol used by the bound object, for a fixed transport protocol, you can only have one base address at most.

Cross-endpoint sharing of addresses:

If several endpoints are specified for a service (where one service only implements one contract), because these endpoints share one service contract, the addresses of these endpoints cannot be shared, and their corresponding addresses must be different. However, when multiple contracts are implemented for a service, several endpoints can share the same binding and address.

The fundamental function of binding objects is to provide communication-based implementation. the WCF system builds a channel stack by binding objects to create a communication bridge.

When the client calls the server, the client endpoint address is generally the responsibility of the automatically generated proxy class. Of course, it can also be determined through ChannelFactory <TChannel> (a Channel attribute of the proxy base class, of course, the automatically generated proxy class is actually implemented by calling the Proxy Base class.

If the address is where the service is deployed and calledAddressHeaderIt is used to control addressing, security creden。, and other issues when the server and client exchange soap messages. In this case, we also need to understand the message exchange in WCF. As a message-based communication framework with a message processing pipeline, messages are routed to an inaccessible location in the pipeline, different processing needs to be performed on messages. Therefore, for message-based communication, addressing is the first priority. Generally, addressing is a problemAddressHeaderSimilar to the control information before data packets.

Similarly, we can specify the control information through programming or configuration --AddressHeader. In use, the control information of the server and client must be completely matched before communication and information exchange can be performed.

Port Sharing helps us better understand the communication problem between processes and the communication problem of WCF.

In peer-to-peer network communication based on TCP/IP, applications that communicate with each other run in their respective application processes. processes at the application layer encapsulate data into data packets, TCP/UDP at the transport layer for network communication, while TCP/UDP identifies different applications through a 16-bit port.

For WCF, when we host a service in a process, it actually listens to and processes client Socket requests.

WCF addressing:

Service providers and service consumers are similar to the server client mode. From the service-oriented perspective (SOA), any object that provides an independent function to the outside world can be called a service.

Message Filtering Problems:

Service, the relationship between the channel distributor and the endpoint distributor:

Service (Service Provider) --> channel distributor (real listening address, physical address) --> endpoint distributor (endpoint provided to service consumers)

Similar to an intermediary, a channel distributor is responsible for receiving and forwarding request messages from service consumers to corresponding service providers, or distributing service endpoints to corresponding service consumers by filtering.

The existence of a channel distributor is largely due to the existence of logical and physical addresses. When no listening address (physical address) is specified, the listening address is the same as the logical address; the logical address is the address we specify using code or configuration.

Message filtering solves the routing selection problem between the channel distributor and the endpoint distributor, that is, the final point selection that is provided to the service consumer is determined. The channel distributor is responsible for request listening (Listening for request information, that is, listening for client request information using the listening address) and message receiving (receiving client request information ), the endpoint distributor completes the final processing of the message. Message filtering is to connect to the received request message and traverse the attributes of the end point distributor stored in itself, after matching, it is sent to the real target endpoint (that is, the endpoint that the Service exposes to the client call ).

The service endpoint is the server, which is also a server in the familiar customer server mode.

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.