WCF chapter one basis more about the configuration file

Service control file web.config or app.config dependent on how the service is lodged, they must contain a <system.serviceModel> node. Under this node, service, binding, behavior, client, diagnosis, extension, boarding environment and COM + Interop can be special settings. There must be a minimum <services> node to contain the endpoint, there are at least one non-infrastructure <endpoint> node in the <services> node. In <endpoint> node, ABCs are defined on each endpoint.

  Address attribute defines the client sends a message to the endpoint URI. For example, if a service-based binding basicHttpBinding HTTP protocol, the URI would be similar http://www.myserver.com:8080/MyService/. If the address is a relative address (and not only a non-empty path), this address will overload the host base address when creating the service. When the service started by the host, WCF start listening, listening New requests on this address. In the case of IIS boarding, listening is likely to start early, so WCF listeners registered on this so that when the request URI soon be redirected to the WCF service.

  Binding attribute defines the communication details that need to connect to the service. It defines the entire channel stack, at least to a channel comprising a network adapter. Also include encryption, compression, and other channels. The system comes with a lot of WCF bindings, such as BasicHttpBinding, compatible with ASMX; WSHttpBinding, to achieve a lot of security, transaction processing, and other advanced features of the more advanced requirements of message-level network services; NetTcpBinding, achieved with the .NET Remoting and DCOM similar fast and secure communication format.

  Contract type attribute references by the service endpoint definition. If there is a MEX endpoint services, WCF will check the type and the MEX endpoint is exposed form of metadata. WCF first look for the type of information from the \ bin folder, and then look in the global buffer of this machine. If you can not find the type of information when the Add Service Reference or WSDL service svcutil.exe request will return an error message to them. If the MEX endpoint does not exist, the service will run well, but the client does not detect their ABCs.  

Lodging content more services
  WCF you can make any type of accommodation in the operating system processes. In most cases, IIS is to achieve performance, manageability and security of the most suitable boarding environment. If you are already running in your environment IIS, in fact you already have a local security deal. Complex id usually well-defined policies and security procedures, and has passed the examination automation tools. Small organizations often use hidden security built on Windows Server 2003 and IIS's. In other cases, existing security will be applied to the behavior in IIS for the boarding of the WCF service.

But there are some reasons to NA IIS boarding. You may want to use the HTTP protocol. You may want to have clear control during startup and shutdown events. Or if you want to provide a custom interface instead of using the IIS management tools. If you do not want to use IIS boarding, no problem. WCF makes self-boarding is very easy to use and extend. Boarding is an example of self-service boarding developers to describe a method of boarding process, rather than relying on IIS or Windows Activation Management Services (Windows Process Activation, WAS).

  The easiest way is to write a boarding services console application, wanted to display the list as 1.1. This method is not very useful in the production process, since the use of the console window is not good behavior on the server, but as a start, it's all going to depend on IIS-based addition. The main program creates an instance of a ServiceHost, like the name suggests, will be the type of accommodation. Calls the Open method ServiceHost and continue. In this case, press the Enter key addition of who do not do anything until the application calls the Close method ServiceHost.

  After the Open method is called, ServiceHost listens for requests on the endpoint specified address. When a message arrives, ServiceHost do a series of things. First, the definition of the stack channel bonding, applying the decryption, decompression and security rules. Then, based on the contract information, to deserialize the received .NET type, to create an object, call the object reflected on the last appropriate method.


===========

forward from

Author: DanielWise
Source: http://www.cnblogs.com/danielWise/
This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page otherwise, the right to pursue legal responsibilities.
 

Reproduced in: https: //www.cnblogs.com/llbofchina/archive/2011/06/24/2089218.html

Guess you like

Origin blog.csdn.net/weixin_33920401/article/details/94206760