Welcome to MSDN Blogs Sign in | Join | Help

Creating Sessions over HTTP

I've got a sessionful contract that I want to use with HTTP. How do I get the HTTP transport to produce a sessionful channel shape?

The basic design principle of channels is that they produce whatever channel shape is their natural message exchange pattern. For HTTP, the natural message exchange pattern is request-reply. This means that if you want any other channel shape, then you need to apply a layered channel that changes the message exchange pattern. That is the approach regardless of whether you want to change the channel shape to one-way, duplex, or a sessionful channel.

There are no built-in HTTP specific additions to create sessionful channels. We have a sample channel that demonstrates creating a session based on HTTP cookies. There are several general-purpose protocol channels that provide sessions, such as security and reliable messaging.

However, this entire line of conversation tends to indicate a fundamental flaw in thinking. A session has the semantic meaning of correlating messages together according to some principle of relationship. Sessionful services use the relationship to treat the session of messages as a connected unit. The meaning of that session ought to be a more significant factor than whether some contract has been previously declared to know about sessions. If you are scrounging around to come up with any possible session to get a service working, then something is probably wrong.

Next time: XML Support

Published Tuesday, August 14, 2007 5:00 AM by Nicholas Allen

Comments

Tuesday, August 14, 2007 12:32 PM by Nicholas Allen's Indigo Blog

# Service Contract Generation

In the post on custom namespaces a few days ago, I used svcutil to generate the service WSDL and schema

Tuesday, August 14, 2007 3:20 PM by EV

# re: Creating Sessions over HTTP

hi, with ASP.Net sessions are straightforward, (the post you linked to related to asmx clients/ server hosts) .

Would appreciate if you can help with general directions for situation when wcf services are hosted by windows services and your clients are flash applications.

The only option i see here is to design sessions system from scratch when session token generated by custom code and stored in cookie that passed by javascript to flax and than transfered by soap headers

Tuesday, August 14, 2007 10:21 PM by Nicholas Allen

# re: Creating Sessions over HTTP

Hi EV,

I'm not sure I see a difference between what you would do in the flash case versus any other type of client.  If you want to pass cookies to the client, then they can be retrieved using javascript or flashvars.  If the client wants to send the cookies back, then flash let's you add http headers to a request.

Wednesday, August 15, 2007 6:14 AM by EV

# re: Creating Sessions over HTTP

Thanks for response, Nicholas.

Http headers is option that i not thought about, it would  sure help.

But regarding all the logic of creating and validating session token + expiration and other policies, am i need to write a custom code for that, or some way exists to utilize asp.net sessions system .

Note that my WCF services hosted by WindowsService and not by iis

Wednesday, August 15, 2007 9:36 PM by Nicholas Allen

# re: Creating Sessions over HTTP

Hi EV,

That's correct that you would probably want some custom code to handle the cookie on the server.  You need to be able to create a cookie string from the instance state and later restore the instance state based on the cookie contents.

New Comments to this post are disabled
 
Page view tracker