Hi, I was trying an example from Ivan Krizsan tutorial to maintain stateful session between requests, but HttpServletRequest is always null when I try to extract it from MessageContext.
This is client :
This is service :
and unfortunately the exception stack trace :
Why I cannot retrieve the HttpServletRequest object ?
There is indeed an error in the example in the study notes, but somehow you seem to have figured it out anyway.
The error is that the printNumber() method in the service endpoint implementation class is annotated with @Oneway. This way, the HTTP response will be closed before the printNumber method is entered and thus no HTTP session will be created (exception will occur).
To make sure that the operation becomes a request-response operation, you can add "throws Exception" to the method declaration.
Also note that the example says that you also are supposed to call the printHTTPSessionID() method from the add() method - this to see that invocations of different operations happens within one and the same session.
Hope this solves your problems!
Joined: Sep 26, 2008
Yes, however thanks on yours suggestions about this issue.
Joined: Oct 04, 2006
I just want to add that I used the exact code that you posted above, developing the web service and client. Then I deployed the web service to GlassFish 2.1 and everything worked as it is supposed to.
If you still have problems, what are you deploying the web service to? Have you made any modifications to the default configuration of the container?