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 Yariel Ramos Moreno <yr...@gmail.com> on 2006/02/21 15:50:14 UTC
Retrieve Web Service name in Axis2
How can I retrieve the name of a Web Service deployed in Axis2 sever in
runtime? I mean, when the service is invoked, I need to get the name of it
from inside it in my code.
Thanks in advance,
Yariel.
Re: Retrieve Web Service name in Axis2
Posted by Jeff Greif <je...@gmail.com>.
Look up javadoc for java.lang.ClassLoader.getSystemResource() or
getSystemResourceAsStream().
Using this, you can have the file in your service's classpath, e.g.
axis/WEB-INF/classes/
Relative to this directory you can name the file
resources/newService/config.xml and get it using
ClassLoader.getSystemResourceAsStream("resources/newService/config.xml");
Jeff
Yariel Ramos Moreno wrote:
> OK... why do I need the service name? Maybe you can give me another
> solution...
>
> I have a XML file into my service, exactly in the root, where there
> are some configuration options for the service work. I most access
> this file from the service classes to get this configuration
> parameters. I'm using System.getProperty("user.dir") to step over the
> tomcat directory, but next I have to concat to this path the rest of
> the path to get the file:
> /webapps/axis2/WEB-INF/services/newsService/config.xml. Is there
> onother way to do this (get the path of an Axis2 web service from the
> service code)?
>
> Thanks again...
>
>
> On 3/18/06, *Deepal Jayasinghe* <deepal@opensource.lk
> <ma...@opensource.lk>> wrote:
>
> hmm , it should work :-/
>
> any at the init method what did you get as your service name , or was
> the AxisServce null , if it is not null then you should be able to get
> the name.
>
Re: Retrieve Web Service name in Axis2
Posted by Deepal Jayasinghe <de...@opensource.lk>.
:)
ohhh , that you can get the location or the file once you have
AxisService in your hand.
by adding init method you can get AxisSrevice (as I told you) , so by
AxisService you can get the file that used to create AxisService
AxisService service = msg.getAxisService();
String location = service.getFileName();
Yariel Ramos Moreno wrote:
> OK... why do I need the service name? Maybe you can give me another
> solution...
>
> I have a XML file into my service, exactly in the root, where there
> are some configuration options for the service work. I most access
> this file from the service classes to get this configuration
> parameters. I'm using System.getProperty("user.dir") to step over the
> tomcat directory, but next I have to concat to this path the rest of
> the path to get the file:
> /webapps/axis2/WEB-INF/services/newsService/config.xml. Is there
> onother way to do this (get the path of an Axis2 web service from the
> service code)?
>
> Thanks again...
>
>
> On 3/18/06, *Deepal Jayasinghe* <deepal@opensource.lk
> <ma...@opensource.lk>> wrote:
>
> hmm , it should work :-/
>
> any at the init method what did you get as your service name , or was
> the AxisServce null , if it is not null then you should be able to get
> the name.
>
>
>
> Yariel Ramos Moreno wrote:
>
> > Hi Deepal:
> >
> > I have tried the procedure you recomended me, but doesn't work... It
> > didn't get the name of the WS... Have you another solution?
> >
> > Thanks for your help...
> >
> >
> >
> > On 2/22/06, *Deepal Jayasinghe* <deepal@opensource.lk
> <ma...@opensource.lk>
> > <mailto:deepal@opensource.lk <ma...@opensource.lk>>> wrote:
> >
> > yes you can do that , meaning if you want to get the name of the
> > service
> > at your service impl class level , you have to following
> procedure.
> > add a new method to service impl class called "init"
> >
> > class MyService {
> > String serviceName;
> > void init(MessageContext msgctx){
> > serviceName = msgctx.getAxisService().getName();
> > }
> > //rest o fthe code
> >
> > public String myMethod(){
> > // you know the name of the sevrice this point
> > }
> > }
> >
> >
> >
> > Yariel Ramos Moreno wrote:
> >
> > > Thanks for your help Deepal...
> > >
> > > I know that. My problem is that I want to get the name of
> my WS
> > in the
> > > moment I invoke it, from one of the clases implemented in
> the WS. I
> > > want to know if there is a class in the Axis2 API that
> alows me
> > to do
> > > that (get my name from code if I'm the invoked WS).
> > >
> > > On 2/22/06, *Deepal Jayasinghe* < deepal@opensource.lk
> <ma...@opensource.lk>
> > <mailto:deepal@opensource.lk <ma...@opensource.lk>>
> > > <mailto:deepal@opensource.lk <ma...@opensource.lk>
> <mailto: deepal@opensource.lk <ma...@opensource.lk>>>> wrote:
> > >
> > > Hi Yariel;
> > >
> > > Name of the service will be the name of the archive
> file if the
> > > services.xml has only one service element meaning if the
> > services.xml
> > > look like below
> > > <service>
> > > ////////// service data
> > > <service>
> > >
> > > In the case of servicegroup name of the service will
> be the
> > name that
> > > you specified in services.xml as an example if the
> > services.xml is
> > > like
> > > below;
> > > <serviceGroup>
> > > <service name="foo">
> > > </service>
> > > </serviceGroup>
> > >
> > > so name of the service will be foo in this case.
> > >
> > > Yariel Ramos Moreno wrote:
> > >
> > > > How can I retrieve the name of a Web Service
> deployed in
> > Axis2 sever
> > > > in runtime? I mean, when the service is invoked, I
> need to
> > get the
> > > > name of it from inside it in my code.
> > > >
> > > > Thanks in advance,
> > > >
> > > > Yariel.
> > >
> > >
> > > --
> > > Thanks,
> > > Deepal
> > >
> ................................................................
> > > ~Future is Open~
> > >
> > >
> > >
> >
> > --
> > Thanks,
> > Deepal
> >
> ................................................................
> > ~Future is Open~
> >
> >
> >
>
> --
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
--
Thanks,
Deepal
................................................................
~Future is Open~
Re: Retrieve Web Service name in Axis2
Posted by Yariel Ramos Moreno <yr...@gmail.com>.
OK... why do I need the service name? Maybe you can give me another
solution...
I have a XML file into my service, exactly in the root, where there are some
configuration options for the service work. I most access this file from the
service classes to get this configuration parameters. I'm using
System.getProperty("user.dir") to step over the tomcat directory, but next I
have to concat to this path the rest of the path to get the file:
/webapps/axis2/WEB-INF/services/newsService/config.xml. Is there onother way
to do this (get the path of an Axis2 web service from the service code)?
Thanks again...
On 3/18/06, Deepal Jayasinghe <de...@opensource.lk> wrote:
>
> hmm , it should work :-/
>
> any at the init method what did you get as your service name , or was
> the AxisServce null , if it is not null then you should be able to get
> the name.
>
>
>
> Yariel Ramos Moreno wrote:
>
> > Hi Deepal:
> >
> > I have tried the procedure you recomended me, but doesn't work... It
> > didn't get the name of the WS... Have you another solution?
> >
> > Thanks for your help...
> >
> >
> >
> > On 2/22/06, *Deepal Jayasinghe* <deepal@opensource.lk
> > <ma...@opensource.lk>> wrote:
> >
> > yes you can do that , meaning if you want to get the name of the
> > service
> > at your service impl class level , you have to following procedure.
> > add a new method to service impl class called "init"
> >
> > class MyService {
> > String serviceName;
> > void init(MessageContext msgctx){
> > serviceName = msgctx.getAxisService().getName();
> > }
> > //rest o fthe code
> >
> > public String myMethod(){
> > // you know the name of the sevrice this point
> > }
> > }
> >
> >
> >
> > Yariel Ramos Moreno wrote:
> >
> > > Thanks for your help Deepal...
> > >
> > > I know that. My problem is that I want to get the name of my WS
> > in the
> > > moment I invoke it, from one of the clases implemented in the WS.
> I
> > > want to know if there is a class in the Axis2 API that alows me
> > to do
> > > that (get my name from code if I'm the invoked WS).
> > >
> > > On 2/22/06, *Deepal Jayasinghe* < deepal@opensource.lk
> > <ma...@opensource.lk>
> > > <mailto:deepal@opensource.lk <ma...@opensource.lk>>>
> wrote:
> > >
> > > Hi Yariel;
> > >
> > > Name of the service will be the name of the archive file if
> the
> > > services.xml has only one service element meaning if the
> > services.xml
> > > look like below
> > > <service>
> > > ////////// service data
> > > <service>
> > >
> > > In the case of servicegroup name of the service will be the
> > name that
> > > you specified in services.xml as an example if the
> > services.xml is
> > > like
> > > below;
> > > <serviceGroup>
> > > <service name="foo">
> > > </service>
> > > </serviceGroup>
> > >
> > > so name of the service will be foo in this case.
> > >
> > > Yariel Ramos Moreno wrote:
> > >
> > > > How can I retrieve the name of a Web Service deployed in
> > Axis2 sever
> > > > in runtime? I mean, when the service is invoked, I need to
> > get the
> > > > name of it from inside it in my code.
> > > >
> > > > Thanks in advance,
> > > >
> > > > Yariel.
> > >
> > >
> > > --
> > > Thanks,
> > > Deepal
> > >
> ................................................................
> > > ~Future is Open~
> > >
> > >
> > >
> >
> > --
> > Thanks,
> > Deepal
> > ................................................................
> > ~Future is Open~
> >
> >
> >
>
> --
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
Re: Retrieve Web Service name in Axis2
Posted by Deepal Jayasinghe <de...@opensource.lk>.
hmm , it should work :-/
any at the init method what did you get as your service name , or was
the AxisServce null , if it is not null then you should be able to get
the name.
Yariel Ramos Moreno wrote:
> Hi Deepal:
>
> I have tried the procedure you recomended me, but doesn't work... It
> didn't get the name of the WS... Have you another solution?
>
> Thanks for your help...
>
>
>
> On 2/22/06, *Deepal Jayasinghe* <deepal@opensource.lk
> <ma...@opensource.lk>> wrote:
>
> yes you can do that , meaning if you want to get the name of the
> service
> at your service impl class level , you have to following procedure.
> add a new method to service impl class called "init"
>
> class MyService {
> String serviceName;
> void init(MessageContext msgctx){
> serviceName = msgctx.getAxisService().getName();
> }
> //rest o fthe code
>
> public String myMethod(){
> // you know the name of the sevrice this point
> }
> }
>
>
>
> Yariel Ramos Moreno wrote:
>
> > Thanks for your help Deepal...
> >
> > I know that. My problem is that I want to get the name of my WS
> in the
> > moment I invoke it, from one of the clases implemented in the WS. I
> > want to know if there is a class in the Axis2 API that alows me
> to do
> > that (get my name from code if I'm the invoked WS).
> >
> > On 2/22/06, *Deepal Jayasinghe* < deepal@opensource.lk
> <ma...@opensource.lk>
> > <mailto:deepal@opensource.lk <ma...@opensource.lk>>> wrote:
> >
> > Hi Yariel;
> >
> > Name of the service will be the name of the archive file if the
> > services.xml has only one service element meaning if the
> services.xml
> > look like below
> > <service>
> > ////////// service data
> > <service>
> >
> > In the case of servicegroup name of the service will be the
> name that
> > you specified in services.xml as an example if the
> services.xml is
> > like
> > below;
> > <serviceGroup>
> > <service name="foo">
> > </service>
> > </serviceGroup>
> >
> > so name of the service will be foo in this case.
> >
> > Yariel Ramos Moreno wrote:
> >
> > > How can I retrieve the name of a Web Service deployed in
> Axis2 sever
> > > in runtime? I mean, when the service is invoked, I need to
> get the
> > > name of it from inside it in my code.
> > >
> > > Thanks in advance,
> > >
> > > Yariel.
> >
> >
> > --
> > Thanks,
> > Deepal
> > ................................................................
> > ~Future is Open~
> >
> >
> >
>
> --
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
--
Thanks,
Deepal
................................................................
~Future is Open~
Re: Retrieve Web Service name in Axis2
Posted by Yariel Ramos Moreno <yr...@gmail.com>.
Hi Deepal:
I have tried the procedure you recomended me, but doesn't work... It didn't
get the name of the WS... Have you another solution?
Thanks for your help...
On 2/22/06, Deepal Jayasinghe <de...@opensource.lk> wrote:
>
> yes you can do that , meaning if you want to get the name of the service
> at your service impl class level , you have to following procedure.
> add a new method to service impl class called "init"
>
> class MyService {
> String serviceName;
> void init(MessageContext msgctx){
> serviceName = msgctx.getAxisService().getName();
> }
> //rest o fthe code
>
> public String myMethod(){
> // you know the name of the sevrice this point
> }
> }
>
>
>
> Yariel Ramos Moreno wrote:
>
> > Thanks for your help Deepal...
> >
> > I know that. My problem is that I want to get the name of my WS in the
> > moment I invoke it, from one of the clases implemented in the WS. I
> > want to know if there is a class in the Axis2 API that alows me to do
> > that (get my name from code if I'm the invoked WS).
> >
> > On 2/22/06, *Deepal Jayasinghe* <deepal@opensource.lk
> > <ma...@opensource.lk>> wrote:
> >
> > Hi Yariel;
> >
> > Name of the service will be the name of the archive file if the
> > services.xml has only one service element meaning if the
> services.xml
> > look like below
> > <service>
> > ////////// service data
> > <service>
> >
> > In the case of servicegroup name of the service will be the name
> that
> > you specified in services.xml as an example if the services.xml is
> > like
> > below;
> > <serviceGroup>
> > <service name="foo">
> > </service>
> > </serviceGroup>
> >
> > so name of the service will be foo in this case.
> >
> > Yariel Ramos Moreno wrote:
> >
> > > How can I retrieve the name of a Web Service deployed in Axis2
> sever
> > > in runtime? I mean, when the service is invoked, I need to get the
> > > name of it from inside it in my code.
> > >
> > > Thanks in advance,
> > >
> > > Yariel.
> >
> >
> > --
> > Thanks,
> > Deepal
> > ................................................................
> > ~Future is Open~
> >
> >
> >
>
> --
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
Re: Retrieve Web Service name in Axis2
Posted by Deepal Jayasinghe <de...@opensource.lk>.
yes you can do that , meaning if you want to get the name of the service
at your service impl class level , you have to following procedure.
add a new method to service impl class called "init"
class MyService {
String serviceName;
void init(MessageContext msgctx){
serviceName = msgctx.getAxisService().getName();
}
//rest o fthe code
public String myMethod(){
// you know the name of the sevrice this point
}
}
Yariel Ramos Moreno wrote:
> Thanks for your help Deepal...
>
> I know that. My problem is that I want to get the name of my WS in the
> moment I invoke it, from one of the clases implemented in the WS. I
> want to know if there is a class in the Axis2 API that alows me to do
> that (get my name from code if I'm the invoked WS).
>
> On 2/22/06, *Deepal Jayasinghe* <deepal@opensource.lk
> <ma...@opensource.lk>> wrote:
>
> Hi Yariel;
>
> Name of the service will be the name of the archive file if the
> services.xml has only one service element meaning if the services.xml
> look like below
> <service>
> ////////// service data
> <service>
>
> In the case of servicegroup name of the service will be the name that
> you specified in services.xml as an example if the services.xml is
> like
> below;
> <serviceGroup>
> <service name="foo">
> </service>
> </serviceGroup>
>
> so name of the service will be foo in this case.
>
> Yariel Ramos Moreno wrote:
>
> > How can I retrieve the name of a Web Service deployed in Axis2 sever
> > in runtime? I mean, when the service is invoked, I need to get the
> > name of it from inside it in my code.
> >
> > Thanks in advance,
> >
> > Yariel.
>
>
> --
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
--
Thanks,
Deepal
................................................................
~Future is Open~
Re: Retrieve Web Service name in Axis2
Posted by Yariel Ramos Moreno <yr...@gmail.com>.
Thanks for your help Deepal...
I know that. My problem is that I want to get the name of my WS in the
moment I invoke it, from one of the clases implemented in the WS. I want to
know if there is a class in the Axis2 API that alows me to do that (get my
name from code if I'm the invoked WS).
On 2/22/06, Deepal Jayasinghe <de...@opensource.lk> wrote:
>
> Hi Yariel;
>
> Name of the service will be the name of the archive file if the
> services.xml has only one service element meaning if the services.xml
> look like below
> <service>
> ////////// service data
> <service>
>
> In the case of servicegroup name of the service will be the name that
> you specified in services.xml as an example if the services.xml is like
> below;
> <serviceGroup>
> <service name="foo">
> </service>
> </serviceGroup>
>
> so name of the service will be foo in this case.
>
> Yariel Ramos Moreno wrote:
>
> > How can I retrieve the name of a Web Service deployed in Axis2 sever
> > in runtime? I mean, when the service is invoked, I need to get the
> > name of it from inside it in my code.
> >
> > Thanks in advance,
> >
> > Yariel.
>
>
> --
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
Re: Retrieve Web Service name in Axis2
Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Yariel;
Name of the service will be the name of the archive file if the
services.xml has only one service element meaning if the services.xml
look like below
<service>
////////// service data
<service>
In the case of servicegroup name of the service will be the name that
you specified in services.xml as an example if the services.xml is like
below;
<serviceGroup>
<service name="foo">
</service>
</serviceGroup>
so name of the service will be foo in this case.
Yariel Ramos Moreno wrote:
> How can I retrieve the name of a Web Service deployed in Axis2 sever
> in runtime? I mean, when the service is invoked, I need to get the
> name of it from inside it in my code.
>
> Thanks in advance,
>
> Yariel.
--
Thanks,
Deepal
................................................................
~Future is Open~