I have several web services. One of this services is used for retrieve a session id (authentication). I pass this id when call other services through SessionInfo. I want to use WCF instead of classic web methods. How can I share one session between several wcf's clients?
As marc_s says you cannot share the session.
But what you can do is to pass the session id as a parameter in your WCF calls, so that you know on whos behalf the call is being made.
Make sure that you use encryption on these calls.
It is not clear what do you mean by session. WCF supports four types of sessions:
- Transport session - for transport protocol which maintains session between server and client. For example: Net.Tcp, Net.Pipe
- Reliable session - support for reliable in order delivery over unreliable channel if both client and server are running
- Security session - client has to be authenticated only for the first call, subsequent calls are authenticated by session token. This session is also called security context.
- Application session - this has a meaning for IsInitiating and IsTerminating parameters of operation contract and PerSession instancing. This session can be used only if any of preceding sessions is used as well = it can't be used in BasicHttpBinding because it doesn't support transport, reliable and security session.
All these sessions are related to communication between single client proxy and single service instance. Nothing else is provided out of the box. Moreover there is no special "session" object.
So what exactly are you trying to achieve? Are you going to replace ASMX services wich are using ASP.NET session? In that case check this sample.
Edit:
The idea about receiving single Id from the first service and reusing this Id on subsequent calls to multiple services should be called corelation (one big activity/transaction) or federation (security related) not session.
The recommanded way to that is by manually maintaining session state between calls. You generate session IDs the way you want and load/persist session information into a database on every call using your own logic.
By doing that, you will support sessions in a way that will enable:
- Load balancing
- Session sharing
- Fail over