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 Andreas Leitner <no...@sbox.tugraz.at> on 2002/08/06 11:21:22 UTC

Session scope not working (beta3)

Hi,

I am currently evaluating Axis for several projects we plan to do here. First of thanks to all ppl involved for such a well written piece of software!

I am having difficulties getting session scope to work as expected. I have done lots of testing in all possible ways - too much to list here :) What I would be interested is to know if session support is currently (beta3) working of broken?

If it is known to work, I can send a more detailed mail describing my test cases. Maybe some kind soul can help me find the solution to my problem.

By the way, interesting enough application scope works as expected of course request scope worked too - only session scope behaved just like request scope.

best regards and many thanks in advance,
Andreas


Re: Session: simpleSessionHandler And Ansynchronized messaging

Posted by yx...@wm.edu.
Hello Tom, 

Thanks for your help, I got it all worked out. The
authorization header is  to inform the client side
authorization granted and time out information for the
subsequent calls to server. 

By the way, does anyone know how to enforce the
services' (calls) order on the server side, if there are
many methods (calls) avaliable in the web service. 

Another question is how to inform the client the server
has timed out. Right now I am using soap header message
to construct the time out information on the server side
and process it in the client side. Does anyone has a
better idea? Or know how to inform the client in an
Asynchronized way from the server side?

Thanks in advance!

Tina  

Re: Session: simpleSessionHandler

Posted by Tom Braun <Th...@hp.com>.
On Wednesday 14 August 2002 18:38, yxlix1@wm.edu wrote:
> I have one more question. When I put/declare the handler
> inside the service, it does not work. But axis says that
> you could define the handler inside a service, or
> global, or in the transport.

are you talking about the client or the server .wsdd?
on the client side there is no <service> entry allowed, thus defining a 
handler herein won't work.
on the server-side however it should (it works in my apps).
 
did you enclose the handler definition in a <requestFlow> or <responseFlow> ?
maybe you could post the .wsdd here?

> And even now, I could not get the messageContext object
> in the client side. when I using the following code
> before the call.invoke() and after it, the msgC is null.

i'm not at all sure here but: 
maybe you could use call.getMessageContext() instead.

>                  }
>                     else {
>                         System.out.println("the
> authorization header is null");
>                     }
>                 } catch (Exception e) {

what are you trying to do? 
i may be wrong but i can't think of authorization headers making sense on the 
client-side.

hope this helped you,

tom

Re: Session: simpleSessionHandler

Posted by yx...@wm.edu.
Hello, Tom,

Thanks for all your help. It works now. The session id
is consistant and I could set the session property in
one call and get it in the following calls in the server
side. 

I have one more question. When I put/declare the handler
inside the service, it does not work. But axis says that
you could define the handler inside a service, or
global, or in the transport. 

And even now, I could not get the messageContext object
in the client side. when I using the following code
before the call.invoke() and after it, the msgC is null.

MessageContext msgC = MessageContext.getCurrentContext();
         System.out.println("get messagecontext before
call invoke\n\n");
            if (msgC != null) {
                System.out.println("messagecontext is
not null");
                Message requestMessage =
msgC.getRequestMessage();
                Message responseMessage =
msgC.getResponseMessage();  
                 }
                    else {
                        System.out.println("the
authorization header is null");
                    }
                } catch (Exception e) {
                    new
org.apache.axis.AxisFault("Failure trying to get the
Message object", e);
                }
            }

Do you have any insight on that, or I am doing something
wrong?

Thanks again, and I am really happy about the session
handler now.

Tina

Quoting Tom Braun <Th...@hp.com>:

> > But I don't know where should I put the
> generated
> > clinet-config.wsdd to let client or axis
> engine know the
> > client want the session info.
> 
> the easiest way is to put the file in the
> directory (or .jar) where your 
> client's .class files reside. for a servelt this
> will be WEB-INF/classes.
> having a stand-alone client, you may specify the
> classpath when
> starting the prog like:
> 
> java -cp path-to-client-conf:path-to-class-files
>     class-containing-main
> 
> or you could set the CLASSPATH environment
> variable befor starting the client.
> 
> tom
> 

Re: Session: simpleSessionHandler

Posted by Tom Braun <Th...@hp.com>.
> But I don't know where should I put the generated
> clinet-config.wsdd to let client or axis engine know the
> client want the session info.

the easiest way is to put the file in the directory (or .jar) where your 
client's .class files reside. for a servelt this will be WEB-INF/classes.
having a stand-alone client, you may specify the classpath when
starting the prog like:

java -cp path-to-client-conf:path-to-class-files     class-containing-main

or you could set the CLASSPATH environment variable befor starting the client.

tom

Re: Session: simpleSessionHandler

Posted by yx...@wm.edu.
hello, Tom,

Thanks for your help. I noticed that I need the file
client-config.wsdd and it may generate by using 
java org.apache.axis.utils.Admin client deploy.wsdd

But I don't know where should I put the generated
clinet-config.wsdd to let client or axis engine know the  
client want the session info. 

Maybe this sound silly, but could you please tell me
where to set the classpath for client or where should I
put that file.

Thanks a lot!

Ying 


Quoting Tom Braun <Th...@hp.com>:

> hi tina,
> you have to insert the the SimpleSessionHandler
> in the client's request and 
> response flows as well.
> this is done by putting a file named
> client-config.wsdd in the client's 
> classpath.
> here is an example:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <deployment name="defaultClientConfig"
>                   
> xmlns="http://xml.apache.org/axis/wsdd/"
>            
>
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
>                                
> xmlns:ns1="urn:SurveyApp">
>   <transport name="http"
>                 
> pivot="java:org.apache.axis.transport.http.HTTPSender">
>     <requestFlow>
>        <handler
>
type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
>     </requestFlow>
> 
>     <responseFlow>
>        <handler
>
type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
>      </responseFlow>
>   </transport>
> </deployment>
> 
> 

Why doesn't deploy except on non-existent classes?

Posted by Colin Sampaleanu <co...@exis.com>.
I find it somewhat annoying (in that it leads to finding out about 
problems later rather than sooner) that calling AdminClient to perform a 
deployment will not throw an error if the class to deploy (as specified 
with the "className" parameter) doesn't actually exist. Instead, you get 
an error when you actually try to call the service.

I suppose I can see the case where it is useful to defer validation 
until actual use, but I think for most users it would be better to 
provide feedback at deployment time that the specified classes do not exist.

I am using Axis from CVS, 2002-8-7. Am I missing something?



Re: Session: simpleSessionHandler

Posted by Tom Braun <Th...@hp.com>.
hi tina,
you have to insert the the SimpleSessionHandler in the client's request and 
response flows as well.
this is done by putting a file named client-config.wsdd in the client's 
classpath.
here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig"
                   xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
                                xmlns:ns1="urn:SurveyApp">
  <transport name="http"
                 pivot="java:org.apache.axis.transport.http.HTTPSender">
    <requestFlow>
       <handler type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
    </requestFlow>

    <responseFlow>
       <handler type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
     </responseFlow>
  </transport>
</deployment>


Basic XML Question

Posted by Anthony Smith <an...@fedex.com>.
How do I pass just an xml page to another server?
I only need to pass this page to a server when a user clicks a link. The
identified user's profile will be what is mainly composed of the XML.


Session: simpleSessionHandler

Posted by yx...@wm.edu.
Hello,

I am trying to use simpleSessionHandler in my project.
And  it does not work. I don't know what is wrong and
please help me.

I did the following:
1. deploy the service as scope = session
2. add simplesession handler in requestFlow and
responseFlow for this service.
3. deploy it by using java
org.apache.axis.client.AdminClient deploy.wsdd
4. set session to true in client side:
binding.setMaintainSession(true)

result: every time I call a function in this service,
the response soap message header has an incresed
sessionId. And the service acts as a response/request
service. Session infomation was not maintained.

I don't know what is wrong with it. And hope somebody
could give me some suggestions and if you could give me
an example of it, I will appreciate it a lot.

I could use http header cookies to make it work, but I
want to make it work by using soap header message. 

All my code is based on wsdl2java, so if you could show
me where I should make change in soapbindingStub or
soapbindingSkeleton, that will be great. I read all the
discussion on session and the simplesession test.java,
but still could not figure it out, Please help!

Lots of thanks!

Tina

Re: Sending more than just beans (Best Practice?)

Posted by Andreas Leitner <no...@sbox.tugraz.at>.
On Wed, Aug 07, 2002 at 09:50:21AM -0700, Ricky Ho wrote:
> At 01:35 PM 8/7/2002 +0200, Andreas Leitner wrote:
> >On Wed, Aug 07, 2002 at 12:27:57PM +0100, Simon Hargreaves wrote:
> If you are using the class autogenerated from the WSDL file, then even 
> custom serializer doesn't help.  Of course, if you define your own "Person" 
> class and use your own custom serializer then it will work.
> Another approach is to write a wrapper class that mirror's the 
> autogenerated Person class and put all your method in the wrapper class.  I 
> think this is the simplest way.
> 
> There is currently NO standard way to return a reference to serviceB from 
> an operation of serviceA.  Of course, an ugly way is to pass the endpoint 
> URL endpoint as a string.


Thanks alot Ricky. I guess I have to think more about it. But your help is very valueable to me.


regards,
Andreas


Re: Sending more than just beans (Best Practice?)

Posted by Ricky Ho <ri...@cisco.com>.
At 01:35 PM 8/7/2002 +0200, Andreas Leitner wrote:
>On Wed, Aug 07, 2002 at 12:27:57PM +0100, Simon Hargreaves wrote:
> > Andreas Leitner wrote:
> >
> > >Hi again,
> > >
> > >now that I have sessions working correctly I am now trying to implement a
> > >simple Client/Server combo.
> > >
> > >I understand from the docs that references cannot be transmitted via 
> soap.
> > >So that in the following scenario (server side):
> > >
> > >class MyService
> > >{
> > >     Person getPersonByName (String name)
> > >     {
> > >             ... lookup person in db and return reference to it...
> > >     }
> > >
> > >}
> > >class Person
> > >{
> > >     private String name;
> > >     private String tel;
> > >     public String getName () {return name}
> > >     public String getTel () {return tel}
> > >     public void setName (String name) {this.name = name;}
> > >     public void setTel (String tel) {this.tel = tel;}
> > >}
> > >--
> > >
> > >I would get on the client side:
> > >--
> > >class MyService
> > >{
> > >     Person getPersonByName (String name)
> > >     { ... do proxy stuff ...}
> > >}
> > >--
> > >which is ok, but class Person would carry only public data and no
> > >operations.
> > >--
> > >class Person
> > >{
> > >     public String name;
> > >     public String tel;
> > >}
> > >--
> > >
> > >
> > Since the client needs to know the class to instantiate it, then the
> > methods are there anyway, they're not transmitted but the methods are
> > common knowledge.
> >
> > Beans need all the properties to be set using getXXX setXXX methods
> > otherwise it's not a bean. Internal state can be read if it's public,
> > and if you don't want to use a bean you can write your own Serializer
> > for that class.
>
>
>Correct in case Server=Axis and Client=Axis. I am sorry I was a bit unclear.
>In case of Server=Axis and Client=.NET the connection is defined via a 
>WSDL file.
>
>I am using the autogenerated WSDL file (the one that I get by appending a 
>'?WSDL' to the services URL).
>In that WSDL file (taken from the above scenario) all information I get 
>about Person is a simple schema, which lists all attributes of Person as a 
>'sequence'. There is of course no way for .NET to make anything more out 
>of that information than a simple class with only attributes.
>
>Is there any way I can force .NET to generate a Stub for Person as 
>detailed as it was generated for MyService?
>
>tia,
>Andreas

If you are using the class autogenerated from the WSDL file, then even 
custom serializer doesn't help.  Of course, if you define your own "Person" 
class and use your own custom serializer then it will work.
Another approach is to write a wrapper class that mirror's the 
autogenerated Person class and put all your method in the wrapper class.  I 
think this is the simplest way.

There is currently NO standard way to return a reference to serviceB from 
an operation of serviceA.  Of course, an ugly way is to pass the endpoint 
URL endpoint as a string.

Rgds, Ricky


Re: Sending more than just beans (Best Practice?)

Posted by Andreas Leitner <no...@sbox.tugraz.at>.
On Wed, Aug 07, 2002 at 12:27:57PM +0100, Simon Hargreaves wrote:
> Andreas Leitner wrote:
> 
> >Hi again,
> >
> >now that I have sessions working correctly I am now trying to implement a 
> >simple Client/Server combo.
> >
> >I understand from the docs that references cannot be transmitted via soap. 
> >So that in the following scenario (server side):
> >
> >class MyService
> >{
> >	Person getPersonByName (String name)
> >	{	
> >		... lookup person in db and return reference to it...
> >	}
> >
> >}
> >class Person
> >{
> >	private String name;
> >	private String tel;
> >	public String getName () {return name}
> >	public String getTel () {return tel}
> >	public void setName (String name) {this.name = name;}
> >	public void setTel (String tel) {this.tel = tel;}
> >}
> >--
> >
> >I would get on the client side:
> >--
> >class MyService
> >{
> >	Person getPersonByName (String name)
> >	{ ... do proxy stuff ...}
> >}
> >--
> >which is ok, but class Person would carry only public data and no 
> >operations.
> >--
> >class Person
> >{
> >	public String name;
> >	public String tel;
> >}
> >--
> > 
> >
> Since the client needs to know the class to instantiate it, then the 
> methods are there anyway, they're not transmitted but the methods are 
> common knowledge.
> 
> Beans need all the properties to be set using getXXX setXXX methods 
> otherwise it's not a bean. Internal state can be read if it's public, 
> and if you don't want to use a bean you can write your own Serializer 
> for that class.


Correct in case Server=Axis and Client=Axis. I am sorry I was a bit unclear.
In case of Server=Axis and Client=.NET the connection is defined via a WSDL file.

I am using the autogenerated WSDL file (the one that I get by appending a '?WSDL' to the services URL).
In that WSDL file (taken from the above scenario) all information I get about Person is a simple schema, which lists all attributes of Person as a 'sequence'. There is of course no way for .NET to make anything more out of that information than a simple class with only attributes.

Is there any way I can force .NET to generate a Stub for Person as detailed as it was generated for MyService?

tia,
Andreas


Re: Sending more than just beans (Best Practice?)

Posted by Simon Hargreaves <si...@openthought.com>.
Andreas Leitner wrote:

>Hi again,
>
>now that I have sessions working correctly I am now trying to implement a simple Client/Server combo.
>
>I understand from the docs that references cannot be transmitted via soap. So that in the following scenario (server side):
>
>class MyService
>{
>	Person getPersonByName (String name)
>	{	
>		... lookup person in db and return reference to it...
>	}
>
>}
>class Person
>{
>	private String name;
>	private String tel;
>	public String getName () {return name}
>	public String getTel () {return tel}
>	public void setName (String name) {this.name = name;}
>	public void setTel (String tel) {this.tel = tel;}
>}
>--
>
>I would get on the client side:
>--
>class MyService
>{
>	Person getPersonByName (String name)
>	{ ... do proxy stuff ...}
>}
>--
>which is ok, but class Person would carry only public data and no operations.
>--
>class Person
>{
>	public String name;
>	public String tel;
>}
>--
>  
>
Since the client needs to know the class to instantiate it, then the 
methods are there anyway, they're not transmitted but the methods are 
common knowledge.

Beans need all the properties to be set using getXXX setXXX methods 
otherwise it's not a bean. Internal state can be read if it's public, 
and if you don't want to use a bean you can write your own Serializer 
for that class.

Simon...

-- 
---------------------------
http://www.openhistory.net
  free the information
---------------------------




Sending more than just beans (Best Practice?)

Posted by Andreas Leitner <no...@sbox.tugraz.at>.
Hi again,

now that I have sessions working correctly I am now trying to implement a simple Client/Server combo.

I understand from the docs that references cannot be transmitted via soap. So that in the following scenario (server side):

class MyService
{
	Person getPersonByName (String name)
	{	
		... lookup person in db and return reference to it...
	}

}
class Person
{
	private String name;
	private String tel;
	public String getName () {return name}
	public String getTel () {return tel}
	public void setName (String name) {this.name = name;}
	public void setTel (String tel) {this.tel = tel;}
}
--

I would get on the client side:
--
class MyService
{
	Person getPersonByName (String name)
	{ ... do proxy stuff ...}
}
--
which is ok, but class Person would carry only public data and no operations.
--
class Person
{
	public String name;
	public String tel;
}
--

Now I can imaging this will work for simple cases, but as classes get more complex, I surely will need more than plain structs. Even if no operations are permitted, a client may not be allowed to set all attributes of an object at will.

Of course such a plain struct has the advantage, that setting an attribute does not require a SOAP call on the other hand.

If I want class Person on the client side to have operations, do I need to write custom serializers/deserializers? How have others solved this problems? Can I combine server webserices - like one webservice for MyService and one for Person, where 'getPersonByName' would somehow return a reference to the WebService 'Person'?

many thanks in advance,
Andreas


Re: Session scope not working (beta3)

Posted by Andreas Leitner <no...@sbox.tugraz.at>.
On Tue, Aug 06, 2002 at 12:59:52PM +0200, Andreas Leitner wrote:
> On Tue, Aug 06, 2002 at 11:45:07AM +0200, Matthias Brunner wrote:
> > On Tuesday 06 August 2002 11:21, Andreas Leitner wrote:
> > > I am having difficulties getting session scope to work as expected. I have
> > > done lots of testing in all possible ways - too much to list here :) What I
> > > would be interested is to know if session support is currently (beta3)
> > > working of broken?
> > >
> > > If it is known to work, I can send a more detailed mail describing my test
> > > cases. Maybe some kind soul can help me find the solution to my problem.
> > 
> > Hello,
> > 
> > session scope is supported in beta3. Have you enabled it on the client side?
> > 
> > Call call    = (Call) service.createCall();
> > call.setMaintainSession(true);

Very nice, I succsessfuly build a Axis (Server) to .NET (Client) connection which is session aware. All you need to do on the .NET side is to add
myService.CookieContainer = new System.Net.CookieContainer ();

regards,
Andreas


Re: Session scope not working (beta3)

Posted by Andreas Leitner <no...@sbox.tugraz.at>.
On Tue, Aug 06, 2002 at 11:45:07AM +0200, Matthias Brunner wrote:
> On Tuesday 06 August 2002 11:21, Andreas Leitner wrote:
> > I am having difficulties getting session scope to work as expected. I have
> > done lots of testing in all possible ways - too much to list here :) What I
> > would be interested is to know if session support is currently (beta3)
> > working of broken?
> >
> > If it is known to work, I can send a more detailed mail describing my test
> > cases. Maybe some kind soul can help me find the solution to my problem.
> 
> Hello,
> 
> session scope is supported in beta3. Have you enabled it on the client side?
> 
> Call call    = (Call) service.createCall();
> call.setMaintainSession(true);

Thanks for the hint. I am using wsdl2java on the client side, to be precise what i do is:

*) I have a simple java bean on the server side (with a setter and a getter)
*) from that i generate a wsdl file
*) from that wsdl file i generate a java client stub
*) i have a junit test case using the java client stub to test the session

All that is driven by ant. Anyway, I have hacked the generated java client stub and inserted after each call creation a call to 'setMaintainaSession' recompiled the stub and rerun the test - same result - no session was maintained.

 
> By default, axis uses HTTP cookies for session management. If you want to 
> change this, you have to define session handlers.
> There is also a session example in the test directory (source version only).

Actually I have now this in my deploy.wsdd
--
<deployment
  xmlns="http://xml.apache.org/axis/wsdd/"
  xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
  xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">

  <handler type="java:org.apache.axis.handlers.SimpleSessionHandler"
    name="SimpleSessionHandler"/>

  <service name="helloworld" provider="java:RPC">

    <parameter name="className" value="at.macron.helloWorldServer.HelloWorld"/>
    <parameter name="allowedMethods" value="*"/>
    <parameter name="scope" value="session"/>

    <requestFlow>
      <handler type="SimpleSessionHandler"/>
    </requestFlow>
    <responseFlow>
      <handler type="SimpleSessionHandler"/>
    </responseFlow>
  </service>
  
</deployment>
--

If I interpret the docs correctly the request flow part sets uses the session handler, while the' parameter name="scope"' element enables cookies (on the server side)

Hmm, I just constructed another test case where I don't generate the stub, but write it myself. Now it seems to work. Strange... Means the server side is correct - thats most important to me, because the java client will be replaced by a .NET client anyway.


Anyway, is there a way to generate stubs which maintain their session by default?

And the question that is most important to me: Has anybody tried wheter the session is maintained if the client is a .NET Application?

many thanks in advance,
Andreas


Re: Session scope not working (beta3)

Posted by Matthias Brunner <mb...@blumenstrasse.vol.at>.
On Tuesday 06 August 2002 11:21, Andreas Leitner wrote:
> Hi,
>
> I am currently evaluating Axis for several projects we plan to do here.
> First of thanks to all ppl involved for such a well written piece of
> software!
>
> I am having difficulties getting session scope to work as expected. I have
> done lots of testing in all possible ways - too much to list here :) What I
> would be interested is to know if session support is currently (beta3)
> working of broken?
>
> If it is known to work, I can send a more detailed mail describing my test
> cases. Maybe some kind soul can help me find the solution to my problem.

Hello,

session scope is supported in beta3. Have you enabled it on the client side?

Call call    = (Call) service.createCall();
call.setMaintainSession(true);

By default, axis uses HTTP cookies for session management. If you want to 
change this, you have to define session handlers.
There is also a session example in the test directory (source version only).
-- 
Matthias Brunner <mb...@blumenstrasse.vol.at>
PGP FP 7862 32B3 3B75 292A F76F  5042 8587 21AB 5B89 D501
Check out http://blumenstrasse.vol.at/~mb/gpgkey.asc