Hi Kalle, 

> -----Original Message-----
> From: Nice To Know [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 22, 2004 11:04 AM
> To: [EMAIL PROTECTED]
> Subject: Web Service with state
> 
> Hi!
> I'm building a web service that need a internal state. This is needed 
> because the web service will start a legacy program that 
> takes input from a 
> prompt. This is my calls:
> 
> int threadId : runProg( String args )
> void sendInput( threadId, String args)
> String getResult( threadId)
> 
> Have read that web service has to be state-less. Why is that?

Where did you read that?
Maybe it's a hint which should be followed if possible, but nothing more
IMHO.
I have to implement such a web service too: I do maintain something like
you called "threadId" to implement sessions (without using HTTPSession!)
and all. My web service clients contact the service, get an initial id,
then ask (by handing over their initial id) for connection ids, then ask
(by handing over a connection id) for database ids and so on.
Works pretty well.

Beyond the scope of your question, just to mention:
One challenge (I haven't actually solved) is HOW to maintain state in
the server in a way clustering of the server side is possible. Right now
I do store my id stuff just in static variables which is a bad idea in a
clustered world (you know, static is per JVM instance ...).

> Unfortunately I have no choice here because I cant rewrite the legacy 
> application.
> 
> Thanks in advance
> 
> /Kalle

cu
   Merten

Reply via email to