Freigeben über


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

Comments

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

  • Anonymous
    August 14, 2007
    The comment has been removed

  • Anonymous
    August 14, 2007
    The comment has been removed

  • Anonymous
    August 14, 2007
    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

  • Anonymous
    August 15, 2007
    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.