Sunday, July 12, 2009

He is unstoppable!!!

Office 2010 - checkout this video, this is really funny. Brilliant!!!

Saturday, July 04, 2009

WCF Sessions

In WCF, sessions are seen as group of ordered conversation in oppose to object centric behavior in ASP.NET. If the messages are exchange with same contract and contract specifies the session, a session is established for these messages. Following are the major differences between asp.net session and WCF session.

ASP.NET

WCF

Session is initiated by the server.

Session is initiated and terminated by the client.

Ordered processing (Messages are processed in sequence).

Unordered Processing

Provides general data storing mechanism

No such mechanism


In simplest form, we can specify session in following way:

[ServiceContract(SessionMode.SessionModeRequired)]

Public interface ICalculator { …}


WCF session has resemblance with local object. So by default, all subsequent requests are handled by same service instance.

Initiating operations are like constructors and Terminating operations are like destructors and requests between these two are like operation called on object.

[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples", SessionMode=SessionMode.Required)]

public interface ICalculatorSession

{

    [OperationContract(IsOneWay=true, IsInitiating=true, IsTerminating=false)]

    void Clear();

    [OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]

    void AddTo(double n);

    [OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]

    void SubtractFrom(double n);

    [OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]

    void MultiplyBy(double n);

    [OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = false)]

    void DivideBy(double n);

    [OperationContract(IsInitiating = false, IsTerminating = true)]

    double Equals();

}


For detail: WCF Sessions.