Search This Blog

Tuesday, September 7, 2010

WCF Services

WCF Services


All communication with a Windows Communication Foundation (WCF) service occurs through the endpoints of the service. Endpoints provide clients access to the functionality offered by a WCF service.

Each endpoint consists of four properties:

An address that indicates where the endpoint can be found. The address uniquely identifies the endpoint and tells potential consumers of the service where it is located. It is represented in the WCF object model by the EndpointAddress class.

A binding that specifies how a client can communicate with the endpoint. The binding specifies how to communicate with the endpoint. This includes:

-The transport protocol to use (for example, TCP or HTTP).

-The encoding to use for the messages (for example, text or binary).

-The necessary security requirements (for example, SSL or SOAP message security).

A contract that identifies the operations available. The contract outlines what functionality the endpoint exposes to the client. A contract specifies:

-What operations can be called by a client.

-The form of the message.

-The type of input parameters or data required to call the operation.

-What type of processing or response message the client can expect.

A set of behaviors that specify local implementation details of the endpoint. You can use endpoint behaviors to customize the local behavior of the service endpoint. Endpoint behaviors achieve this by participating in the process of building a WCF runtime. An example of an endpoint behavior is the ListenUri property, which allows you to specify a different listening address than the SOAP or Web Services Description Language (WSDL) address.

Data transfer and serialization in WCF service.

The Windows Communication Foundation (WCF) can be thought of as a messaging infrastructure. Service operations can receive messages, process them, and send them messages. Messages are described using operation contracts. For example, consider the following contract.

[ServiceContract] - This shows what services are offered to the client.

[OperationContract] - This shows what operations are exposed within the service to the client.

[DataContract] - This is used when the parameter passed need to act as both for request and reply messages. They makes use of DataContractSerializer.

[MessageContract] - This is used to represent the request and the reply message using single type. This can be implemented using datacontract also. But message contract avoids unnecessary levels of wrapping in the resultant xml. Also, message contracts can specify what shld be the message body and what shld be message header.

Sessions, Instancing, and Concurrency in Windows Communication Foundation

A session is a correlation of all messages sent between two endpoints. Instancing refers to controlling the lifetime of user-defined service objects and their related InstanceContext objects. Concurrency is the term given to the control of the number of threads executing in an InstanceContext at the same time.

No comments:

Post a Comment