Instance Management in WCF Part # 4(END)

No.of Views1543
Bookmarked0 times
Downloads 
Votes0
By  Dhananjay Kumar   On  24 Oct 2010 01:10:25
Tag : WCF , General
This article will give theoretical introduction and explanation of coding sample also. It will explain 2 full coding sample that how to work with Session ID in WCF.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

This article is part # 4 of Instance Management in WCF. This article will explain how to work with Session ID in WCF. This article will give theoretical introduction and explanation of coding sample also. It will explain 2 full coding sample that how to work with Session ID in WCF.

  • Part # 1 of this series could be found Part 1
  • Part # 2 of this series could be found Part 2
  • Part # 3 of this series could be found Part 3

Note: There is no any attached code with this article because; I have amended same sample to give different demonstration. I am sorry for that, but once you will go through article, you will able to understand the concept behind.

 The Session ID

Image Loading
  1. Every session has a unique Session ID.
  2. Both client and service can obtain and use the Session ID.
  3. The Session ID is in form of GUID.
  4. The main use of Session ID is in logging.
Image Loading

Session ID at Server side

 1.Every Service operation has an operation call context accessible via the operational class.
 2.A Service can obtain a reference to the operation context of current method via the Current static method of the OperationConext class. 

Image Loading

Session ID at client side 

Image Loading

Fetching Session ID at client for a Per-Session configured service (Sample #1)

In below code sample

   1.Service is configured as Session full service.
   2.SessionMode of contract of service is set to Required.
   3.Client is referencing the service and creating different proxies.
   4.Expected output is ,

Image Loading

Service Interface (Contract) 

Image Loading

Service 

Image Loading

Client 

Image Loading

Output 

Image Loading
Image Loading

Comparing Session ID at client and Service for a Per-Session configured service (Sample #2)

In below code sample

   1.Service is configured as Session full service.
   2.SessionMode of contract of service is set to Required.
   3.Service is exposing one Operation Contract, which is returning Session ID for a particular operation context.
   4.Client is creating a Proxy and fetching the session ID.
   5.There is a comparison between Session Id returned by service and Session Id fetched by client for a particular session. Whether both session ID is same or not.

Service Interface (Contract) 

Image Loading

Service  

Image Loading

Client 

Image Loading

Output 

Image Loading
Image Loading

Conclusion

This article explained about, Session ID in WCF. This article gave theoretical introduction and explanation of coding sample also.

 
Sign Up to vote for this article
 
About Author
 
Dhananjay Kumar
Occupation-Software Engineer
Company-Infosys Technolgies,Pune
Member Type-Gold
Location-India
Joined date-20 Jul 2009
Home Page-http://dhananjaykumar.net/
Blog Page-http://dhananjaykumar.net/
Dhananjay Kumar is Microsoft MVP on connected system. He blogs at http://dhananjaykumar.net/ . You can follow him http://twitter.com/debugmode_/ and reach him at dhananjay.25july@gmail.com
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top