You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Vickram Jain <vi...@collabra.ca> on 2007/05/02 18:37:39 UTC

[Axis2] Other ways of doing sessions w/o addressing

Is there a way to generate sessions without using the WS-Addressing module? 

The consumer for my application has trouble dealing with XML as it is, and so keeping our message pared down is important. I'd hate to have to fatten up my messages at this point. 

If this is not possible, then one other question: is addressing module only set to respond with a session token only if the caller uses the addressing headers?

Re: [Axis2] Other ways of doing sessions w/o addressing

Posted by robert lazarski <ro...@gmail.com>.
http://braziloutsource.com/wss2.html

Search for 'SWA Session State' . The explanation and javadoc are in
portuguese - if google translate isn't clear enough feel free to ask here.

UUIDCache in that code is managed by ehcache - here's the config:

<ehcache>

    <diskStore path="java.io.tmpdir"/>

    <cache name="UUID_CACHE"
        maxElementsInMemory="100"
        eternal="false"
        timeToIdleSeconds="1800"
        timeToLiveSeconds="1800"
        overflowToDisk="true"
        diskPersistent="true"
        memoryStoreEvictionPolicy="LFU"
        />
</ehcache>

I use spring to set up ehcache as:

<bean id="uuidCache" class="
org.springframework.cache.ehcache.EhCacheFactoryBean">
        <property name="cacheManager">
            <ref local="cacheManager"/>
        </property>
        <property name="cacheName">
            <value>com.siemens.swa.webservices.security.UUIDCache</value>
        </property>
</bean>

UUIDCache is:

package com.siemens.swa.webservices.security;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/** Manage UUID's and its variables via a Singleton. **/
public class UUIDCache {

    /** Singleton instance. */
    private static UUIDCache _instance;

    /** Used to hold references to web vars resources for re-use. */
    private Map < String, Long > timeCache;

    /**
    Constructor.

    intializes the static server properties
    */
    private UUIDCache() {
        try {
            timeCache = Collections.synchronizedMap(
                    new HashMap< String, Long >());
        } catch (Exception ex) {
            throw new IllegalStateException("Cache constructor exception: "
                + ex.toString());
        }
    }

    //Instatiate singleton with a static initializer
    static {
        try {
            _instance = new UUIDCache();
            System.out.println("Simple cache started successfully");
        } catch (Exception e) {
            throw new ExceptionInInitializerError(e);
        }
    }

    /**
    returns the instance of the UUIDCache.
    <p>
     @return UUIDCache - the singleton.
    */
    public static UUIDCache getInstance() {
        return _instance;
    }

    /**
    Verify user has logged in.

    @param  who  The Session key
    @return Integer webId
    */
    public boolean hasSOAPSession(String who) {
        return timeCache.containsKey(who);
    }

    /**
    Gets timestamp var as Long.

    @param  who  The Session key
    @return timestamp timeout var
    */
    public Long getTimeStamp(String who) {
        Long timestamp = null;
        try {
            if (timeCache.containsKey(who)) {
                timestamp = timeCache.get(who);
            } else {
                throw new IllegalStateException(
                        "Corrupted cache detected - "
                        + " getTimeStamp() can't find key: "
                        + who);
            }
        } catch (Exception ex) {
            throw new IllegalStateException(
                    "Cache getWebID exception: " + ex.toString());
        }

        return timestamp;
    }

    /**
    Put webId into cache.

    @param  who  The Session key
    @param  timestamp timeout var
    */
    public void putTimeStamp(String who, Long timestamp) {
        if (timeCache.containsKey(who)) {
            // remove old lease
            timeCache.remove(who);
        }
        timeCache.put(who, timestamp);
    }

}

Its pretty simple code really.

HTH,
Robert

On 5/3/07, Vickram Jain <vi...@collabra.ca> wrote:
>
>  Robert,
>
> Do you have any code samples on how you setup and used ehcache w/ axis2?
> Would appreciate anything you could send my way.
>
> Thanks,
> Vickram
>
> ----- Original Message -----
> *From:* robert lazarski <ro...@gmail.com>
> *To:* axis-user@ws.apache.org
> *Sent:* Wednesday, May 02, 2007 2:13 PM
> *Subject:* Re: [Axis2] Other ways of doing sessions w/o addressing
>
> You can manage the sessions yourself by generating your own token via a
> return value and mandate the passing of it back in a future calls, but then
> you have to manage the token yourself. That does have the advantage of after
> a few days work its stable and flexible. I've done that with both ehcache /
> UUID and alternatively ejb stateful session beans.
>
> HTH,
> Robert
>
> On 5/2/07, Glen Mazza <gr...@verizon.net> wrote:
> >
> > Can't answer your second question, but the first one may be "no".  The
> > bottom of page 1 of the below article states "Managing a SOAP session
> > requires you to engage addressing modules on both the server side and
> > client side":
> >
> > http://www.developer.com/java/web/article.php/3620661
> >
> > Hopefully a more advanced user can think of another option for you.
> >
> > Glen
> >
> >
> > Am Mittwoch, den 02.05.2007, 12:37 -0400 schrieb Vickram Jain:
> > > Is there a way to generate sessions without using the WS-Addressing
> > > module?
> > >
> > > The consumer for my application has trouble dealing with XML as it is,
> >
> > > and so keeping our message pared down is important. I'd hate to have
> > > to fatten up my messages at this point.
> > >
> > > If this is not possible, then one other question: is addressing module
> > > only set to respond with a session token only if the caller uses the
> > > addressing headers?
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>

Re: [Axis2] Other ways of doing sessions w/o addressing

Posted by Vickram Jain <vi...@collabra.ca>.
Robert,

Do you have any code samples on how you setup and used ehcache w/ axis2? Would appreciate anything you could send my way.

Thanks,
Vickram
  ----- Original Message ----- 
  From: robert lazarski 
  To: axis-user@ws.apache.org 
  Sent: Wednesday, May 02, 2007 2:13 PM
  Subject: Re: [Axis2] Other ways of doing sessions w/o addressing


  You can manage the sessions yourself by generating your own token via a return value and mandate the passing of it back in a future calls, but then you have to manage the token yourself. That does have the advantage of after a few days work its stable and flexible. I've done that with both ehcache / UUID and alternatively ejb stateful session beans. 

  HTH,
  Robert 


  On 5/2/07, Glen Mazza <gr...@verizon.net> wrote:
    Can't answer your second question, but the first one may be "no".  The
    bottom of page 1 of the below article states "Managing a SOAP session
    requires you to engage addressing modules on both the server side and 
    client side":

    http://www.developer.com/java/web/article.php/3620661

    Hopefully a more advanced user can think of another option for you. 

    Glen


    Am Mittwoch, den 02.05.2007, 12:37 -0400 schrieb Vickram Jain:
    > Is there a way to generate sessions without using the WS-Addressing
    > module?
    >
    > The consumer for my application has trouble dealing with XML as it is, 
    > and so keeping our message pared down is important. I'd hate to have
    > to fatten up my messages at this point.
    >
    > If this is not possible, then one other question: is addressing module
    > only set to respond with a session token only if the caller uses the 
    > addressing headers?


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org 
    For additional commands, e-mail: axis-user-help@ws.apache.org




Re: [Axis2] Other ways of doing sessions w/o addressing

Posted by robert lazarski <ro...@gmail.com>.
You can manage the sessions yourself by generating your own token via a
return value and mandate the passing of it back in a future calls, but then
you have to manage the token yourself. That does have the advantage of after
a few days work its stable and flexible. I've done that with both ehcache /
UUID and alternatively ejb stateful session beans.

HTH,
Robert

On 5/2/07, Glen Mazza <gr...@verizon.net> wrote:
>
> Can't answer your second question, but the first one may be "no".  The
> bottom of page 1 of the below article states "Managing a SOAP session
> requires you to engage addressing modules on both the server side and
> client side":
>
> http://www.developer.com/java/web/article.php/3620661
>
> Hopefully a more advanced user can think of another option for you.
>
> Glen
>
>
> Am Mittwoch, den 02.05.2007, 12:37 -0400 schrieb Vickram Jain:
> > Is there a way to generate sessions without using the WS-Addressing
> > module?
> >
> > The consumer for my application has trouble dealing with XML as it is,
> > and so keeping our message pared down is important. I'd hate to have
> > to fatten up my messages at this point.
> >
> > If this is not possible, then one other question: is addressing module
> > only set to respond with a session token only if the caller uses the
> > addressing headers?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Re: [Axis2] Other ways of doing sessions w/o addressing

Posted by Glen Mazza <gr...@verizon.net>.
Can't answer your second question, but the first one may be "no".  The
bottom of page 1 of the below article states "Managing a SOAP session
requires you to engage addressing modules on both the server side and
client side":

http://www.developer.com/java/web/article.php/3620661

Hopefully a more advanced user can think of another option for you.

Glen


Am Mittwoch, den 02.05.2007, 12:37 -0400 schrieb Vickram Jain:
> Is there a way to generate sessions without using the WS-Addressing
> module? 
>  
> The consumer for my application has trouble dealing with XML as it is,
> and so keeping our message pared down is important. I'd hate to have
> to fatten up my messages at this point. 
>  
> If this is not possible, then one other question: is addressing module
> only set to respond with a session token only if the caller uses the
> addressing headers?


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org