MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

WCF

WCF Examples

WCF

WCF Projects

WCF Project

Per-Session Services
Previous Home Next

Per service endpoint per proxy is the client session.

If the client creates another proxy to the same or a different endpoint then that second proxy will be associated with a new instance and session.

Configuring Private Sessions:

A session has three elements

  1. behavior,
  2. binding,
  3. contract.

 

The behavior part is used  for that WCF will keep the service instance alive throughout the session and to direct the client messages to it.

This local behavior is created by setting the InstanceContextMode property of the ServiceBehavior attribute to InstanceContextMode.PerSession:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
class MyService : IMyContract
{...}

Since InstanceContextMode.PerSession is the default value of the InstanceContextMode property, these definitions are equivalent:

class MyService : IMyContract
{...}
[ServiceBehavior]
class MyService : IMyContract
{...}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
class MyService : IMyContract
{...}
SessionMode.Allowed

SessionMode.Allowed is the default value of the property, so these definitions are equivalent:

[ServiceContract]
interface IMyContract
{...}

[ServiceContract(SessionMode = SessionMode.Allowed)]
interface IMyContract
{...}

Example Per-session service and client

///////////////////////// Service code /////////////////////
[ServiceContract(SessionMode = SessionMode.Required)]
interface IMyContract
{
[OperationContract]
void operation( );
}
class MyService : IMyContract,IDisposable
{
int flag= 0;
MyService( )
{
Trace.WriteLine("MyService.MyService( )");
}
public void operation( )
{
flag++;
Trace.WriteLine("Counter = " + flag);
}
public void Dispose( )
{
Trace.WriteLine("MyService.Dispose( )");
}
}
///////////////////////// Client code /////////////////////
MyContractClient proxy = new MyContractClient( );
proxy.operation( );
proxy.operation( );
proxy.Close( );
//Output
MyService.MyService( )
Counter = 1
Counter = 2
MyService.Dispose( )
Previous Home Next