Hi Jen;
 
At which point do you want to access those parameter ? , if you want that inside a handler you have everything that you want to get parameters.
 
If you want to access that inside you service methods the way is this
  1. add a method called init(MessageContex) in your service implementation class , by the message receiver by default that method will be called (messagecontext injection)
  2. You can keep that in your service class and use that inside your methods
 
as an example
 
class MyService {
 
MessageContext mc;
 
public void init(MessageContext mc){
  this.mc = mc;
}
 
public void echoString(String str){
   Paramter par = mc.getParamter("myParaName");
   // rest of your code
}
 
}

Thanks,
 Deepal
................................................................
~Future is Open~
----- Original Message -----
From: Jen-Ya Ku
Sent: Friday, September 23, 2005 12:24 AM
Subject: RE: Axis2 - how to get service/operation level parameter

Hi, Deepal:
 
Thanks a lot for your information.  messageContext.getParameter() is good enough.
But how to get MessageContext from axis2 service?
 
In axis2 (axis2-0-91.jar), the API "MessageContext.getCurrentContext()" doesn't exist.   How to get MessageContext for axis2? Do I miss anything?
 
Thanks,
Jen-Ya
-----------------------------------------------------------------------------------------------------
Hi Jen;

The first and correct way is  messageContext.getParamter(String prename),  but you \
can only called this method after  dispatching taking place. The second way is you \
can get those parameter by applying following procedure.

  1. get the Axis
  2. service =  axisConfig.get(Service)
  3. service.get(paramterName)
  4. operation = service.getOpeartion(Opiate);
  5. operation.getParamter(paramtername)

But the second way has some problem because top level parameter can override by \
bottom level parameter , in this way those override parameter wont be visible.

Thanks,
Deepal


From: Jen-Ya Ku
Sent: Wednesday, September 21, 2005 3:29 PM
To: [email protected]
Cc: Jen-Ya Ku
Subject: Axis2 - how to get service/operation level parameter

Hi, All:
 
In Axis2, is it possible to define service level or operation level parameter for each service?
For example, can I have service.xml like following?
-----------------------------------------------------------------
<service name="MyService">
      ...
       <parameter name="my-service-level-parameter-name">my-parameter-value</parameter>
    -----
    <operation name="ixxx">     
            <parameter name="my-operation-level-parameter">my-parameter-value</parameter>
     </operation>
  </service>
-----------------------------------------------------------------
Also, which API I should use to get these parameters from my service in Axis2 (MessageContext.getCurrentContext seems gone in Axis2) ? 
 
Thanks for your help.
 
Thanks,
Jen-Ya
 
 

Reply via email to