WCF's full name is: Windows commnication FOUNDATION.WCF, is Microsoft to a series of industry standard definition of implementation, is the service-oriented implementation of a better way. The traditional three-layer structure pattern is generally: data access layer, business logic layer, customer layer, but the client layer and the business logic layer are coupled tightly in this mode, and service oriented makes the customer layer and the business logic loose coupling.
Address
Each service of WCF requires one address, and only one, and WCF supports multiple transports:
1.HTTP
2.TCP
3. Peer-to-peer Network
4. Internal Process Communication
5.MSMQ
The usual address includes two aspects: 1. Service location, 2. protocol for transmission. such as TCP based address: Net.tcp://localhost:8800/henllyee.service, where net.tcp is the transport protocol, and the following is to tell the location of the service.
Contract
WCF all services are publicly available as contracts, when you use this service is more than about following certain contracts. The expression of the contract would like to WebService in the expression, but also through the attribute tag to identify. WCF defines four types of contracts:
1. Service Contract: Defines the service operations that a client can perform.
2. Data Contract: Data types defined for service interactions.
3. Error contract (Fault Contract): Defines the error thrown.
4. Message Contract: Defines a message that interacts directly with the service.
Service contracts are widely used, and defining a service contract is simple, and is identified on some service interfaces.
Namespace Henllyeewcf.service
{
[ServiceContract (namespace= "http://henllyee.cnblogs.com")]
public Interface Ihello
{
[OperationContract]
string SayHello (string strName);
Public
class Hello:ihello
{public
string SayHello (string strName)
{return
Str Ing. Format ("{0} Say hello at {1}", StrName, DateTime.Now.ToString ());
}
}