You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Jean-Michel PATER <pa...@cogenit.fr> on 2006/09/15 15:43:06 UTC
[AXIS2] Acces servlet context parameters
Hi all,
How can I get context parameters from a Web Service ?
Should I get an instance of AxisServlet or to MessageContext, and how
can I init them ?
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: [AXIS2] Acces servlet context parameters
Posted by Jean-Michel PATER <pa...@cogenit.fr>.
Hi,
I solved my problem using MessageContext.
In the setOperationContext of the implementation class, I use the
following code to initialize ServletContext
> public void setOperationContext(OperationContext opContext) {
>
> try {
> MessageContext msgCtx =
> opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
> if (msgCtx == null) {
> log.error("message context not initialized");
> return;
> }
> ServletContext servletCtx =
> (ServletContext)msgCtx.getProperty(Constants.SERVLET_CONTEXT);
> }
> catch (AxisFault e) {
> e.printStackTrace();
> }
>
>
> if (servletCtx == null) {
> log.error(" servlet context not initialized");
> return;
> }
> carsDB = (CarsDB)servletCtx.getAttribute("carsCB");
>
>
>
> }
Jean-Michel PATER wrote:
> Hi,
>
> I may missed something. I have implemented the setOperationContext
> method in my service implementation class (in the skeleton class). I
> have then a method like that in my skeleton :
>
>> public void setOperationContext(OperationContext opContext){
>> log.info("Entering setOperationContext");
>> ServiceContext serviceCtx = opContext.getServiceContext();
>> ConfigurationContext configCtx =
>> serviceCtx.getConfigurationContext();
>> if(configCtx == null) {
>> log.error("setOperationContext --> configuration
>> context not initialized");
>> return;
>> } servletCtx =
>> (ServletContext)configCtx.getProperty("transport.http.servletContext");
>> if(servletCtx == null) {
>> log.error("setOperationContext --> servlet context
>> not initialized");
>> return;
>> }
>> CarsDB carsDB =
>> (CarsDB)servletCtx.getAttribute("carsCB");
>> }
>
>
> But I always have " servlet context not initialized " in my log file.
>
> The receiver class is the receiver generated from the WSDL2Java
> command line which extends
> org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver
>
>
> Deepal Jayasinghe wrote:
>> You can do it using one step;
>>
>> (ServletContext)operationContext.getProperty(transport.http.servletContext);
>>
>>
>> Thanks
>> Deepal
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
--
Jean-Michel PATER <pa...@cogenit.fr>
Cogenit Tél : +33 (0) 1 40 20 08 43
53 rue Sainte Anne Fax : +33 (0) 1 40 20 08 45
75002 Paris <URL:http://www.cogenit.fr>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: [AXIS2] Acces servlet context parameters
Posted by Jean-Michel PATER <pa...@cogenit.fr>.
Hi,
I may missed something. I have implemented the setOperationContext
method in my service implementation class (in the skeleton class). I
have then a method like that in my skeleton :
> public void setOperationContext(OperationContext opContext){
> log.info("Entering setOperationContext");
> ServiceContext serviceCtx = opContext.getServiceContext();
> ConfigurationContext configCtx =
> serviceCtx.getConfigurationContext();
> if(configCtx == null) {
> log.error("setOperationContext --> configuration
> context not initialized");
> return;
> }
> servletCtx =
> (ServletContext)configCtx.getProperty("transport.http.servletContext");
>
> if(servletCtx == null) {
> log.error("setOperationContext --> servlet context not
> initialized");
> return;
> }
>
>
> CarsDB carsDB =
> (CarsDB)servletCtx.getAttribute("carsCB");
>
> }
But I always have " servlet context not initialized " in my log file.
The receiver class is the receiver generated from the WSDL2Java command
line which extends
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver
Deepal Jayasinghe wrote:
> You can do it using one step;
>
> (ServletContext)operationContext.getProperty(transport.http.servletContext);
>
> Thanks
> Deepal
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: [AXIS2] Acces servlet context parameters
Posted by Deepal Jayasinghe <de...@opensource.lk>.
You can do it using one step;
(ServletContext)operationContext.getProperty(transport.http.servletContext);
Thanks
Deepal
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: [AXIS2] Acces servlet context parameters
Posted by Thilina Gunarathne <cs...@gmail.com>.
You can access the operation context from your service impl as given
in the following FAQ.
http://www.wso2.net/kb/106
Then you can get the service context from the operation context.
After that you can get the ServletContext from ConfigurationContext
ServletContext servletContext =
(ServletContext)configCtx.getProperty("transport.http.servletContext");
~Thilina
On 9/15/06, Jean-Michel PATER <pa...@cogenit.fr> wrote:
> Hi all,
>
> How can I get context parameters from a Web Service ?
>
> Should I get an instance of AxisServlet or to MessageContext, and how
> can I init them ?
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>
--
"May the SourcE be with u"
http://webservices.apache.org/~thilina/
http://thilinag.blogspot.com/
http://www.bloglines.com/blog/Thilina
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org