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 "Naveen Kumar.M" <Na...@erunway.com> on 2002/04/12 13:37:33 UTC

How to access MessageContext in a Web service?

>  Hi,
> 	We have implemented a EJB as a web service. And our requirement is
> to access MessageContext object in the web service(EJB) methods.
> 	1. We tried accessing it MessageContext object by passing it from
> the client to a method of the web service(EJB) but it was giving an
> exception
> 	at the client side (IndexOutOfBoundsException ArrayList.....). 
> 	2. We also tried directly accessing MessageContext by using static
> method in MessageContext class getCurrentContext() but it was returning
> null.
>  	3. We read in the book "Building Services with Java" that we can
> have access to the MessageContext in the web services. The example they
> gave is 
> 	not working.
> 
> 	Please let us know if anyone has any idea or a sample code.
> 
> Thanks & Regards,
> Naveen & Kavish

RE: How to access MessageContext in a Web service?

Posted by Chris Haddad <ch...@cobia.net>.
Naveen - 

MessageContext is not passed from the client to the service.  It is
created by the Axis engine from the SOAP/HTTP information and passed to
the service.

If you desire to pass information from the client to the service, it
needs to either be an HTTP header or a SOAP part.


To access MessageContext from the service, you call the static
getCurrentContext() method. For example:

MessageContext oMC = MessageContext.getCurrentContext();
   
>From the message context, you have access to most everything; including
the HttpServletRequest, Basic Authentication info, SOAP Headers, ....

Have fun,

/Chris


-----Original Message-----
From: Naveen Kumar.M [mailto:NaveenM@erunway.com] 
Sent: Friday, April 12, 2002 7:38 AM
To: axis-user@xml.apache.org
Subject: How to access MessageContext in a Web service?


>  Hi,
> 	We have implemented a EJB as a web service. And our requirement
is
> to access MessageContext object in the web service(EJB) methods.
> 	1. We tried accessing it MessageContext object by passing it
from
> the client to a method of the web service(EJB) but it was giving an
> exception
> 	at the client side (IndexOutOfBoundsException ArrayList.....). 
> 	2. We also tried directly accessing MessageContext by using
static
> method in MessageContext class getCurrentContext() but it was
returning
> null.
>  	3. We read in the book "Building Services with Java" that we can
> have access to the MessageContext in the web services. The example
they
> gave is 
> 	not working.
> 
> 	Please let us know if anyone has any idea or a sample code.
> 
> Thanks & Regards,
> Naveen & Kavish