[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

how to manage session with SOAP Header

Trapulo

1/23/2003 12:23:00 PM

I'd like to use SOAP Headers to send a sessionID from the client to the
webservice. That's fine. But I've a big problem: where I put the
SessionID-UserID HashTable to validate the sessionID values the webservice
receives?

Not in db (too long to execute for my goals). I can put it in Application
Object, but then how can I remove expored sessions and not to use a lot of
memory?
Any other idea?

thanks




6 Answers

Manni

1/23/2003 1:08:00 PM

0

I had the same aproach (if I understand you right), I made a solution
with the Cache object!

So I dont have to manualy remove "old" items, since there is a timeout!
It's almost like Session, but there is no need for the "SessionID-cookie".

My problem was that MS didnt implemt the CookieContainer in .NET CF.

So what I did was --
create a class (with the attributes I need to save in "Session").
The next was to add a static function "GET(string SessionID)" to that class!

With that I can get an instance of my class like this

public void MyWM(string sessionID) {
MySess va=MySess.Get(Cache, sessionID);
int nSomeThing;
nSomeThing=MySess.SavedInt;
//and so on

To first generate it I use a "Initial SessionID" like:
public string StartMethod(.......) {
MySess va=MySess.Get(Cache, Context.......SessionID);
.......
return(Context....SessionID); // use from the client in subsequent calls!!!


So last not least what does the MySess in Get???

public static MySess Get(Cache cx,string SessionID) {
MySess msTmp;
if(cx[SessionID]==null) {
msTmp=new MySess(......);
cx.Insert(SessionID,msTmp,DURATION); //where duration is the TTL for that object!
}
return (MySess)cx[SessionID];
}

So what have I got??
A "Session-Environment" where I pass the SessionID as parameter in my WS calls.
It has Timeouts (restarted with every access - even read - to the object!!!!!)

What I need (client) -- the call of an "INIT" Method returning that SessionID.

Hope this helps!

Manfred


(Bill Cheng (MS))

1/24/2003 2:55:00 AM

0

Hi,

Manfred's suggestion is good. Caching is a very useful feature in ASP.NET.
For more information, you may refer to the following article:

307225.KB.EN-US INFO: ASP.NET Caching Overview
http://support.microsoft.com/default.aspx?scid=KB;EN...

To enable session support in web service, refer to the following article:
http://msdn.microsoft.com/library/en-us/dnservice/html/service08...

If you have any questions, please feel free to reply this post.


This posting is provided "AS IS" with no warranties, and confers no rights.

Regards,

Bill Cheng
Microsoft Support Engineer
--------------------
| From: "Trapulo" <nonscrivermi@qui.it>
| Subject: how to manage session with SOAP Header
| Date: Thu, 23 Jan 2003 12:23:08 +0100
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <uO9lbGtwCHA.1096@TK2MSFTNGP10>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
| NNTP-Posting-Host: host157-169.pool62211.interbusiness.it 62.211.169.157
| Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP10
| Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webservices:14788
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
|
| I'd like to use SOAP Headers to send a sessionID from the client to the
| webservice. That's fine. But I've a big problem: where I put the
| SessionID-UserID HashTable to validate the sessionID values the webservice
| receives?
|
| Not in db (too long to execute for my goals). I can put it in Application
| Object, but then how can I remove expored sessions and not to use a lot of
| memory?
| Any other idea?
|
| thanks
|
|
|
|
|

Trapulo

1/24/2003 3:43:00 PM

0


"Manni" <pcpohler@hotmail.com> wrote in message
news:uP4qTgtwCHA.2668@TK2MSFTNGP12...
> I had the same aproach (if I understand you right), I made a solution
> with the Cache object!
>
> So I dont have to manualy remove "old" items, since there is a timeout!
> It's almost like Session, but there is no need for the "SessionID-cookie".

Yes, I thought it also. But when the application has memory problem, I know
that the runtime clear the cache object, doesn't it?


"The server itself can remove an item from the Cache when it needs to free
memory (scavenging)", from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/c...
l/cpcondeletingitemsfromcache.asp.
So it is not sure I can get my "session's data" where I try to read them.

It is a good idea to use a "not-consistent" data store?

thanks



Trapulo

1/24/2003 3:50:00 PM

0


"Bill Cheng [MSFT]" <billcheng@online.microsoft.com> wrote in message
news:uKR7lu0wCHA.2148@cpmsftngxa08...
> Hi,
>
> Manfred's suggestion is good. Caching is a very useful feature in ASP.NET.

Yes, but I have some doubts about data consistance. Please refer to my reply
to Manfred.

> For more information, you may refer to the following article:
>
> 307225.KB.EN-US INFO: ASP.NET Caching Overview
> http://support.microsoft.com/default.aspx?scid=KB;EN...
>
> To enable session support in web service, refer to the following article:
> http://msdn.microsoft.com/library/en-us/dnservice/html/service08...
>

Yes, but my requirements was to not user cookie or url-based methods, but
use SOAP header or parameters.

thanks



Manni

1/24/2003 4:07:00 PM

0

Yes, you ar rigth!
There is such a problem (dont think the framework clears the Cache for fun or so).
I stressed my server (with the funny stress toll), and I had to do a lot, to have this happen!

So think what your doing, and think what you suppose!!!

Let's go back to your question -- sessionstate-simulation :-) was the thing you wanted!

Try to touch your "web.config" or your global.aspx.
An new app instance will start - session is gone!

Or yust for a little - disconnect your client - sessioncokkie lost - sessionstat gone!
Or, or.........

What I want to tell you is that the cache is cleard (or "shrinked") only in special circumstands.
So for my meaning it's not much unsaver to use the cache than the real session-state!

And if duration is important for you neither session-state nor cache is the best place for this.
You have to use a storage wich is not volatile -- use a DB or an XML-File.
You can do this on demand, wich means, you have to store every change, but you dont have to read from there.
Only in the event of a problem you access the DB to "refresh" your objects!

Manfred


(Bill Cheng (MS))

1/24/2003 5:39:00 PM

0

Hi,

Besides Manfred's suggestions, there are other two things to consider when
you use Cache API:
1. Do not cache too many items. It is easy to go overboard and try to cache
everything. There is a cost for caching an item, especially in memory
utilization, so avoid caching items that could be easily re-computed or any
item that would rarely be used again.

2. Do not put items with fast expiration. Caches work best if items can
live there for long periods of time. Fast expiring items often cause high
churn rate of the cache, providing little benefit and often more work for
the cache cleanup code (as well as the GC, etc.). The ASP.NET Applications,
Cache Total Turnover Rate gives you the overall churn rate of the cache. A
high rate could be something of concern, especially if it occurs due to
memory pressure (i.e. items removed before their expiration).


This posting is provided "AS IS" with no warranties, and confers no rights.

Regards,

Bill Cheng
Microsoft Support Engineer
--------------------
| From: "Trapulo" <nonscrivermi@qui.it>
| References: <uO9lbGtwCHA.1096@TK2MSFTNGP10>
<uKR7lu0wCHA.2148@cpmsftngxa08>
| Subject: Re: how to manage session with SOAP Header
| Date: Fri, 24 Jan 2003 15:50:05 +0100
| Lines: 26
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <OmcVte7wCHA.2396@TK2MSFTNGP10>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
| NNTP-Posting-Host: host157-169.pool62211.interbusiness.it 62.211.169.157
| Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP10
| Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webservices:14830
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
|
|
| "Bill Cheng [MSFT]" <billcheng@online.microsoft.com> wrote in message
| news:uKR7lu0wCHA.2148@cpmsftngxa08...
| > Hi,
| >
| > Manfred's suggestion is good. Caching is a very useful feature in
ASP.NET.
|
| Yes, but I have some doubts about data consistance. Please refer to my
reply
| to Manfred.
|
| > For more information, you may refer to the following article:
| >
| > 307225.KB.EN-US INFO: ASP.NET Caching Overview
| > http://support.microsoft.com/default.aspx?scid=KB;EN...
| >
| > To enable session support in web service, refer to the following
article:
| >
http://msdn.microsoft.com/library/en-us/dnservice/html/service08...
| >
|
| Yes, but my requirements was to not user cookie or url-based methods, but
| use SOAP header or parameters.
|
| thanks
|
|
|
|