You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by so...@fwd.at on 2002/11/10 14:52:11 UTC

Storing data across SOAP method invocations

Hi there!

Does anyone know how it could be done e.g. using Tomcat to store some 
Hashtables across all method invocations for a soap request? Since the 
class seems to get instantiiated every time, how it is possible to ask for 
the values of the last invocation without having to query a database?

I'd like to initialize e.g. configuration data when the first soap request 
comes, so all others don't have to re-read from disc...

thx alot
johannes





Re: Storing data across SOAP method invocations

Posted by Scott Nichol <sn...@scottnichol.com>.
In your service, you can access the HttpSession by doing the following.

1. Add an initial parameter of SOAPContext to each method you want to
access session data, e.g.

    String echoString(String s)

   should be changed to

    String echoString(SOAPContext ctx, String s)

2. Get the session from the SOAPContext property bag

    HTTPSession session = (HTTPSession)
ctx.getProperty(Constants.BAG_HTTPSESSION)

3. Now use the session to set or retrieve values, e.g.

    String lastString = session.getAttribute("lastString");
    session.setAttribute("lastString", s);

Scott Nichol

----- Original Message -----
From: <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Sunday, November 10, 2002 8:52 AM
Subject: Storing data across SOAP method invocations


> Hi there!
>
> Does anyone know how it could be done e.g. using Tomcat to store some
> Hashtables across all method invocations for a soap request? Since the
> class seems to get instantiiated every time, how it is possible to ask
for
> the values of the last invocation without having to query a database?
>
> I'd like to initialize e.g. configuration data when the first soap
request
> comes, so all others don't have to re-read from disc...
>
> thx alot
> johannes
>
>
>
>
>


------------------------------------------------------------------------
--------


> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>


Re: Storing data across SOAP method invocations

Posted by Scott Nichol <sn...@scottnichol.com>.
In your service, you can access the HttpSession by doing the following.

1. Add an initial parameter of SOAPContext to each method you want to
access session data, e.g.

    String echoString(String s)

   should be changed to

    String echoString(SOAPContext ctx, String s)

2. Get the session from the SOAPContext property bag

    HTTPSession session = (HTTPSession)
ctx.getProperty(Constants.BAG_HTTPSESSION)

3. Now use the session to set or retrieve values, e.g.

    String lastString = session.getAttribute("lastString");
    session.setAttribute("lastString", s);

Scott Nichol

----- Original Message -----
From: <so...@fwd.at>
To: <so...@xml.apache.org>
Sent: Sunday, November 10, 2002 8:52 AM
Subject: Storing data across SOAP method invocations


> Hi there!
>
> Does anyone know how it could be done e.g. using Tomcat to store some
> Hashtables across all method invocations for a soap request? Since the
> class seems to get instantiiated every time, how it is possible to ask
for
> the values of the last invocation without having to query a database?
>
> I'd like to initialize e.g. configuration data when the first soap
request
> comes, so all others don't have to re-read from disc...
>
> thx alot
> johannes
>
>
>
>
>


------------------------------------------------------------------------
--------


> --
> To unsubscribe, e-mail:
<ma...@xml.apache.org>
> For additional commands, e-mail:
<ma...@xml.apache.org>


--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>