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 Chandra Talluri <ct...@netnumber.com> on 2003/06/26 22:56:20 UTC

How to maintain the session using HttpClient in AXIS, with Tomcat Server

Hi

Hi,

Using CommonsHTTPSender& HttpClint I can open a connection and do multiple
requests/responses without closing. But Now I can not able to maintain the
session. In every call I get a new session

Actually for every call on server side I get a new ServletEndpointContext :(

In the client I am calling stub.setMaintainSession(true);

Server code snippet is

public class Processor implements ServiceLifecycle
{
    public void doIt(String pid,String name)
    {
        System.out.println("Context :" + this.context.toString());// Every
time I get new one
        javax.servlet.http.HttpSession session = context.getHttpSession();
        System.out.println(session.getId());// Obviously this is different

    }

    public void destroy()  //never called
    {
        System.out.println("Called Destroy");
        this.context = null;
    }

    public void init(Object ctx) throws javax.xml.rpc.ServiceException
    {
       if(this.context == null);
       {
         System.out.println("Called Init"); //For every call it comes here
         this.context = (ServletEndpointContext) ctx;
       }
    }
    private ServletEndpointContext context = null;

}

This is problem is not there If I use HTTPSender. But that won't keep
connections open :(

Thanks in advance
-Chandra Talluri
NetNumber.com, Inc.
650 Suffolk Street
Suite 307
Lowell, MA 01854
Tel: 978-848-2841
ctalluri@netnumber.com
http://www.netnumber.com


Re: How to maintain the session using HttpClient in AXIS, with Tomcat Server

Posted by Davanum Srinivas <di...@yahoo.com>.
No. I did not create a bug....

-- dims

--- Chandra Talluri <ct...@netnumber.com> wrote:
> Thanks dims
> 
> Did you create a bug for this. If so what is bug number
> 
> -Chandra
> ----- Original Message -----
> From: "Davanum Srinivas" <di...@yahoo.com>
> To: <ax...@ws.apache.org>
> Sent: Saturday, June 28, 2003 3:16 PM
> Subject: Re: How to maintain the session using HttpClient in AXIS, with
> Tomcat Server
> 
> 
> > Chandra,
> >
> > Checked in the code. Please try it out. Next time, PLEASE follow
> instructions for submitting a
> > patch
> (http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches
> )
> >
> > Thanks,
> > dims
> >
> > --- Chandra Talluri <ct...@netnumber.com> wrote:
> > > Hi dims
> > >
> > >   I did modifications to CommonsHTTPSender.java for maintaining
> sessions.
> > >
> > >  Cookies needed to be set on
> > >   HttpState not on MessageContext, since HttpMethodBase overwrites the
> > > cookies
> > >   from HttpState. Also we need to setCookiePolicy on HttpState to
> > >   CookiePolicy.COMPATIBILITY, else it is defaulting to RFC2109Spec which
> > > adds
> > >   Version information to it and tomcat server not recognizing it
> > >
> > > Now it maintains the sessions
> > >
> > > I am enclosing the file. Have a look at it and see can it be added to
> AXIS
> > > base code, Since you are the author you are the best person to review
> this
> > > code :)
> > >
> > > -Thanks
> > > Chandra
> > >
> > > ----- Original Message -----
> > > From: "Davanum Srinivas" <di...@yahoo.com>
> > > To: <ax...@ws.apache.org>; <ct...@netnumber.com>
> > > Sent: Thursday, June 26, 2003 7:53 PM
> > > Subject: Re: How to maintain the session using HttpClient in AXIS, with
> > > Tomcat Server
> > >
> > >
> > > > Take a look at the axis code
> > > org\apache\axis\transport\http\CommonsHTTPSender.java. Tweak it if
> > > > needed and send in a patch
> > > >
> > >
> (http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches
> > > )
> > > >
> > > > Thanks,
> > > > -- dims
> > > >
> > > > --- Chandra Talluri <ct...@netnumber.com> wrote:
> > > > > Hi,
> > > > >
> > > > > Using CommonsHTTPSender& HttpClint I can open a connection and do
> > > multiple
> > > > > requests/responses without closing. But Now I can not able to
> maintain
> > > the
> > > > > session. In every call I get a new session
> > > > >
> > > > > Actually for every call on server side I get a new
> > > ServletEndpointContext :(
> > > > >
> > > > > In the client I am calling stub.setMaintainSession(true);
> > > > >
> > > > > Server code snippet is
> > > > >
> > > > > public class Processor implements ServiceLifecycle
> > > > > {
> > > > >     public void doIt(String pid,String name)
> > > > >     {
> > > > >         System.out.println("Context :" + this.context.toString());//
> > > Every
> > > > > time I get new one
> > > > >         javax.servlet.http.HttpSession session =
> > > context.getHttpSession();
> > > > >         System.out.println(session.getId());// Obviously this is
> > > different
> > > > >
> > > > >     }
> > > > >
> > > > >     public void destroy()  //never called
> > > > >     {
> > > > >         System.out.println("Called Destroy");
> > > > >         this.context = null;
> > > > >     }
> > > > >
> > > > >     public void init(Object ctx) throws
> javax.xml.rpc.ServiceException
> > > > >     {
> > > > >        if(this.context == null);
> > > > >        {
> > > > >          System.out.println("Called Init"); //For every call it
> comes
> > > here
> > > > >          this.context = (ServletEndpointContext) ctx;
> > > > >        }
> > > > >     }
> > > > >     private ServletEndpointContext context = null;
> > > > >
> > > > > }
> > > > >
> > > > > This is problem is not there If I use HTTPSender. But that won't
> keep
> > > > > connections open :(
> > > > >
> > > > > Thanks in advance
> > > > > -Chandra Talluri
> > > > > NetNumber.com, Inc.
> > > > > 650 Suffolk Street
> > > > > Suite 307
> > > > > Lowell, MA 01854
> > > > > Tel: 978-848-2841
> > > > > ctalluri@netnumber.com
> > > > > http://www.netnumber.com
> > > > >
> > > >
> > > >
> > > > =====
> > > > Davanum Srinivas - http://webservices.apache.org/~dims/
> > > >
> > > > __________________________________
> > > > Do you Yahoo!?
> > > > SBC Yahoo! DSL - Now only $29.95 per month!
> > > > http://sbc.yahoo.com
> > > >
> > > >
> > > >
> > >
> >
> > > ATTACHMENT part 2 application/octet-stream name=CommonsHTTPSender.java
> >
> >
> >
> > =====
> > Davanum Srinivas - http://webservices.apache.org/~dims/
> >
> > __________________________________
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
> > http://sbc.yahoo.com
> >
> 
> 


=====
Davanum Srinivas - http://webservices.apache.org/~dims/

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Re: How to maintain the session using HttpClient in AXIS, with Tomcat Server

Posted by Chandra Talluri <ct...@netnumber.com>.
Thanks dims

Did you create a bug for this. If so what is bug number

-Chandra
----- Original Message -----
From: "Davanum Srinivas" <di...@yahoo.com>
To: <ax...@ws.apache.org>
Sent: Saturday, June 28, 2003 3:16 PM
Subject: Re: How to maintain the session using HttpClient in AXIS, with
Tomcat Server


> Chandra,
>
> Checked in the code. Please try it out. Next time, PLEASE follow
instructions for submitting a
> patch
(http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches
)
>
> Thanks,
> dims
>
> --- Chandra Talluri <ct...@netnumber.com> wrote:
> > Hi dims
> >
> >   I did modifications to CommonsHTTPSender.java for maintaining
sessions.
> >
> >  Cookies needed to be set on
> >   HttpState not on MessageContext, since HttpMethodBase overwrites the
> > cookies
> >   from HttpState. Also we need to setCookiePolicy on HttpState to
> >   CookiePolicy.COMPATIBILITY, else it is defaulting to RFC2109Spec which
> > adds
> >   Version information to it and tomcat server not recognizing it
> >
> > Now it maintains the sessions
> >
> > I am enclosing the file. Have a look at it and see can it be added to
AXIS
> > base code, Since you are the author you are the best person to review
this
> > code :)
> >
> > -Thanks
> > Chandra
> >
> > ----- Original Message -----
> > From: "Davanum Srinivas" <di...@yahoo.com>
> > To: <ax...@ws.apache.org>; <ct...@netnumber.com>
> > Sent: Thursday, June 26, 2003 7:53 PM
> > Subject: Re: How to maintain the session using HttpClient in AXIS, with
> > Tomcat Server
> >
> >
> > > Take a look at the axis code
> > org\apache\axis\transport\http\CommonsHTTPSender.java. Tweak it if
> > > needed and send in a patch
> > >
> >
(http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches
> > )
> > >
> > > Thanks,
> > > -- dims
> > >
> > > --- Chandra Talluri <ct...@netnumber.com> wrote:
> > > > Hi,
> > > >
> > > > Using CommonsHTTPSender& HttpClint I can open a connection and do
> > multiple
> > > > requests/responses without closing. But Now I can not able to
maintain
> > the
> > > > session. In every call I get a new session
> > > >
> > > > Actually for every call on server side I get a new
> > ServletEndpointContext :(
> > > >
> > > > In the client I am calling stub.setMaintainSession(true);
> > > >
> > > > Server code snippet is
> > > >
> > > > public class Processor implements ServiceLifecycle
> > > > {
> > > >     public void doIt(String pid,String name)
> > > >     {
> > > >         System.out.println("Context :" + this.context.toString());//
> > Every
> > > > time I get new one
> > > >         javax.servlet.http.HttpSession session =
> > context.getHttpSession();
> > > >         System.out.println(session.getId());// Obviously this is
> > different
> > > >
> > > >     }
> > > >
> > > >     public void destroy()  //never called
> > > >     {
> > > >         System.out.println("Called Destroy");
> > > >         this.context = null;
> > > >     }
> > > >
> > > >     public void init(Object ctx) throws
javax.xml.rpc.ServiceException
> > > >     {
> > > >        if(this.context == null);
> > > >        {
> > > >          System.out.println("Called Init"); //For every call it
comes
> > here
> > > >          this.context = (ServletEndpointContext) ctx;
> > > >        }
> > > >     }
> > > >     private ServletEndpointContext context = null;
> > > >
> > > > }
> > > >
> > > > This is problem is not there If I use HTTPSender. But that won't
keep
> > > > connections open :(
> > > >
> > > > Thanks in advance
> > > > -Chandra Talluri
> > > > NetNumber.com, Inc.
> > > > 650 Suffolk Street
> > > > Suite 307
> > > > Lowell, MA 01854
> > > > Tel: 978-848-2841
> > > > ctalluri@netnumber.com
> > > > http://www.netnumber.com
> > > >
> > >
> > >
> > > =====
> > > Davanum Srinivas - http://webservices.apache.org/~dims/
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > SBC Yahoo! DSL - Now only $29.95 per month!
> > > http://sbc.yahoo.com
> > >
> > >
> > >
> >
>
> > ATTACHMENT part 2 application/octet-stream name=CommonsHTTPSender.java
>
>
>
> =====
> Davanum Srinivas - http://webservices.apache.org/~dims/
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
>



Re: How to maintain the session using HttpClient in AXIS, with Tomcat Server

Posted by Davanum Srinivas <di...@yahoo.com>.
Chandra,

Checked in the code. Please try it out. Next time, PLEASE follow instructions for submitting a
patch (http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches)

Thanks,
dims

--- Chandra Talluri <ct...@netnumber.com> wrote:
> Hi dims
> 
>   I did modifications to CommonsHTTPSender.java for maintaining sessions.
> 
>  Cookies needed to be set on
>   HttpState not on MessageContext, since HttpMethodBase overwrites the
> cookies
>   from HttpState. Also we need to setCookiePolicy on HttpState to
>   CookiePolicy.COMPATIBILITY, else it is defaulting to RFC2109Spec which
> adds
>   Version information to it and tomcat server not recognizing it
> 
> Now it maintains the sessions
> 
> I am enclosing the file. Have a look at it and see can it be added to AXIS
> base code, Since you are the author you are the best person to review this
> code :)
> 
> -Thanks
> Chandra
> 
> ----- Original Message -----
> From: "Davanum Srinivas" <di...@yahoo.com>
> To: <ax...@ws.apache.org>; <ct...@netnumber.com>
> Sent: Thursday, June 26, 2003 7:53 PM
> Subject: Re: How to maintain the session using HttpClient in AXIS, with
> Tomcat Server
> 
> 
> > Take a look at the axis code
> org\apache\axis\transport\http\CommonsHTTPSender.java. Tweak it if
> > needed and send in a patch
> >
> (http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches
> )
> >
> > Thanks,
> > -- dims
> >
> > --- Chandra Talluri <ct...@netnumber.com> wrote:
> > > Hi,
> > >
> > > Using CommonsHTTPSender& HttpClint I can open a connection and do
> multiple
> > > requests/responses without closing. But Now I can not able to maintain
> the
> > > session. In every call I get a new session
> > >
> > > Actually for every call on server side I get a new
> ServletEndpointContext :(
> > >
> > > In the client I am calling stub.setMaintainSession(true);
> > >
> > > Server code snippet is
> > >
> > > public class Processor implements ServiceLifecycle
> > > {
> > >     public void doIt(String pid,String name)
> > >     {
> > >         System.out.println("Context :" + this.context.toString());//
> Every
> > > time I get new one
> > >         javax.servlet.http.HttpSession session =
> context.getHttpSession();
> > >         System.out.println(session.getId());// Obviously this is
> different
> > >
> > >     }
> > >
> > >     public void destroy()  //never called
> > >     {
> > >         System.out.println("Called Destroy");
> > >         this.context = null;
> > >     }
> > >
> > >     public void init(Object ctx) throws javax.xml.rpc.ServiceException
> > >     {
> > >        if(this.context == null);
> > >        {
> > >          System.out.println("Called Init"); //For every call it comes
> here
> > >          this.context = (ServletEndpointContext) ctx;
> > >        }
> > >     }
> > >     private ServletEndpointContext context = null;
> > >
> > > }
> > >
> > > This is problem is not there If I use HTTPSender. But that won't keep
> > > connections open :(
> > >
> > > Thanks in advance
> > > -Chandra Talluri
> > > NetNumber.com, Inc.
> > > 650 Suffolk Street
> > > Suite 307
> > > Lowell, MA 01854
> > > Tel: 978-848-2841
> > > ctalluri@netnumber.com
> > > http://www.netnumber.com
> > >
> >
> >
> > =====
> > Davanum Srinivas - http://webservices.apache.org/~dims/
> >
> > __________________________________
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
> > http://sbc.yahoo.com
> >
> >
> >
> 

> ATTACHMENT part 2 application/octet-stream name=CommonsHTTPSender.java



=====
Davanum Srinivas - http://webservices.apache.org/~dims/

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Re: How to maintain the session using HttpClient in AXIS, with Tomcat Server

Posted by Chandra Talluri <ct...@netnumber.com>.
Hi dims

  I did modifications to CommonsHTTPSender.java for maintaining sessions.

 Cookies needed to be set on
  HttpState not on MessageContext, since HttpMethodBase overwrites the
cookies
  from HttpState. Also we need to setCookiePolicy on HttpState to
  CookiePolicy.COMPATIBILITY, else it is defaulting to RFC2109Spec which
adds
  Version information to it and tomcat server not recognizing it

Now it maintains the sessions

I am enclosing the file. Have a look at it and see can it be added to AXIS
base code, Since you are the author you are the best person to review this
code :)

-Thanks
Chandra

----- Original Message -----
From: "Davanum Srinivas" <di...@yahoo.com>
To: <ax...@ws.apache.org>; <ct...@netnumber.com>
Sent: Thursday, June 26, 2003 7:53 PM
Subject: Re: How to maintain the session using HttpClient in AXIS, with
Tomcat Server


> Take a look at the axis code
org\apache\axis\transport\http\CommonsHTTPSender.java. Tweak it if
> needed and send in a patch
>
(http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches
)
>
> Thanks,
> -- dims
>
> --- Chandra Talluri <ct...@netnumber.com> wrote:
> > Hi,
> >
> > Using CommonsHTTPSender& HttpClint I can open a connection and do
multiple
> > requests/responses without closing. But Now I can not able to maintain
the
> > session. In every call I get a new session
> >
> > Actually for every call on server side I get a new
ServletEndpointContext :(
> >
> > In the client I am calling stub.setMaintainSession(true);
> >
> > Server code snippet is
> >
> > public class Processor implements ServiceLifecycle
> > {
> >     public void doIt(String pid,String name)
> >     {
> >         System.out.println("Context :" + this.context.toString());//
Every
> > time I get new one
> >         javax.servlet.http.HttpSession session =
context.getHttpSession();
> >         System.out.println(session.getId());// Obviously this is
different
> >
> >     }
> >
> >     public void destroy()  //never called
> >     {
> >         System.out.println("Called Destroy");
> >         this.context = null;
> >     }
> >
> >     public void init(Object ctx) throws javax.xml.rpc.ServiceException
> >     {
> >        if(this.context == null);
> >        {
> >          System.out.println("Called Init"); //For every call it comes
here
> >          this.context = (ServletEndpointContext) ctx;
> >        }
> >     }
> >     private ServletEndpointContext context = null;
> >
> > }
> >
> > This is problem is not there If I use HTTPSender. But that won't keep
> > connections open :(
> >
> > Thanks in advance
> > -Chandra Talluri
> > NetNumber.com, Inc.
> > 650 Suffolk Street
> > Suite 307
> > Lowell, MA 01854
> > Tel: 978-848-2841
> > ctalluri@netnumber.com
> > http://www.netnumber.com
> >
>
>
> =====
> Davanum Srinivas - http://webservices.apache.org/~dims/
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
>
>
>

Re: How to maintain the session using HttpClient in AXIS, with Tomcat Server

Posted by Davanum Srinivas <di...@yahoo.com>.
Take a look at the axis code org\apache\axis\transport\http\CommonsHTTPSender.java. Tweak it if
needed and send in a patch
(http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SubmitPatches)

Thanks,
-- dims

--- Chandra Talluri <ct...@netnumber.com> wrote:
> Hi
> 
> Hi,
> 
> Using CommonsHTTPSender& HttpClint I can open a connection and do multiple
> requests/responses without closing. But Now I can not able to maintain the
> session. In every call I get a new session
> 
> Actually for every call on server side I get a new ServletEndpointContext :(
> 
> In the client I am calling stub.setMaintainSession(true);
> 
> Server code snippet is
> 
> public class Processor implements ServiceLifecycle
> {
>     public void doIt(String pid,String name)
>     {
>         System.out.println("Context :" + this.context.toString());// Every
> time I get new one
>         javax.servlet.http.HttpSession session = context.getHttpSession();
>         System.out.println(session.getId());// Obviously this is different
> 
>     }
> 
>     public void destroy()  //never called
>     {
>         System.out.println("Called Destroy");
>         this.context = null;
>     }
> 
>     public void init(Object ctx) throws javax.xml.rpc.ServiceException
>     {
>        if(this.context == null);
>        {
>          System.out.println("Called Init"); //For every call it comes here
>          this.context = (ServletEndpointContext) ctx;
>        }
>     }
>     private ServletEndpointContext context = null;
> 
> }
> 
> This is problem is not there If I use HTTPSender. But that won't keep
> connections open :(
> 
> Thanks in advance
> -Chandra Talluri
> NetNumber.com, Inc.
> 650 Suffolk Street
> Suite 307
> Lowell, MA 01854
> Tel: 978-848-2841
> ctalluri@netnumber.com
> http://www.netnumber.com
> 


=====
Davanum Srinivas - http://webservices.apache.org/~dims/

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

How to maintain the session using HttpClient in AXIS, with Tomcat Server

Posted by Chandra Talluri <ct...@netnumber.com>.
Just some more info

I am also adding

  <parameter name="scope" value="session"/>

to the wsdd file while deploying

If I don't add this destroy being called as expected for every request

-----Original Message-----
From: Chandra Talluri [mailto:ctalluri@netnumber.com]
Sent: Thursday, June 26, 2003 4:56 PM
To: Axis-User (E-mail)
Subject: How to maintain the session using HttpClient in AXIS, with
Tomcat Server

Hi,

Using CommonsHTTPSender& HttpClint I can open a connection and do multiple
requests/responses without closing. But Now I can not able to maintain the
session. In every call I get a new session

Actually for every call on server side I get a new ServletEndpointContext :(

In the client I am calling stub.setMaintainSession(true);

Server code snippet is

public class Processor implements ServiceLifecycle
{
    public void doIt(String pid,String name)
    {
        System.out.println("Context :" + this.context.toString());// Every
time I get new one
        javax.servlet.http.HttpSession session = context.getHttpSession();
        System.out.println(session.getId());// Obviously this is different

    }

    public void destroy()  //never called
    {
        System.out.println("Called Destroy");
        this.context = null;
    }

    public void init(Object ctx) throws javax.xml.rpc.ServiceException
    {
       if(this.context == null);
       {
         System.out.println("Called Init"); //For every call it comes here
         this.context = (ServletEndpointContext) ctx;
       }
    }
    private ServletEndpointContext context = null;

}

This is problem is not there If I use HTTPSender. But that won't keep
connections open :(

Thanks in advance
-Chandra Talluri
NetNumber.com, Inc.
650 Suffolk Street
Suite 307
Lowell, MA 01854
Tel: 978-848-2841
ctalluri@netnumber.com
http://www.netnumber.com