WCF, Begin/End asynch, OperationContext.Current

lordofduct

Well-known member
Joined
Jun 24, 2010
Messages
71
Programming Experience
3-5
So I have a WCF service that runs, and sometimes I want to call to the server asynchronously.

Basically I follow the Begin/End outline to do the call. WCF takes care of a asynchronous call when I do this, which means I'm not struck with any 'timeouts' if the service takes a while, it just responds back once it's done. Yey.

On the service I grab a reference to the current OperationContext so I can get the sessionId. I have a few persistent values stored by the sessionId... so this way I know who called and what of these values to use.

But the thing is OperationContext.Current is NOTHING if I do this Begin/End asynch call to the WCF service. Does anyone know why? Does anyone know how I can work around this?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,604
Location
Norway
Programming Experience
10+
Most likely you are using default BasicHttpBinding, which doesn't support sessions.
 

lordofduct

Well-known member
Joined
Jun 24, 2010
Messages
71
Programming Experience
3-5
nope...

the object is there if I don't do an asynch begin/end call

I'm using ws

And I just tested, because that sounds weird, and OperationContext.Current does exist in BasicHttpBinding.
 
Last edited:

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,604
Location
Norway
Programming Experience
10+
According to my tests OperationContext.Current does exist in BasicHttpBinding both for sync/ascyn calls, but it never has a session id. According to my research, for example System-Provided Bindings, it also shouldn't since that binding does not support sessions. I was only able to get an id string using other types of bindings, and there were also no difference with sync/async calls.
 
Top Bottom