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 vairamuthu thayapavan <vt...@vijayaba.cse.mrt.ac.lk> on 2003/09/01 06:12:49 UTC

Re: Passing parameters to constructor

hi
i think u mean the ws classes in axis. for that 1st specify a default
constructor with out any parameter. then specify ur constructor with
required parameter.
-
thayapavan
----- Original Message -----
From: "Massimo Barabino" <ms...@virgilio.it>
To: <ax...@ws.apache.org>
Sent: Friday, August 29, 2003 9:01 PM
Subject: Passing parameters to constructor


> Hi all,
> does anybody know if there is a way to pass parameters to the
> constructor of the java class invoked by axis (I'm using 1.1)?
>
> I' ve seen the constructor is always called. If the constructor doesn' t
> require any parameter it is executed and everything goes fine. If the
> constructor requires parameters I get a fault code when I invoke the
> service.
> Can anybody help me?
> Thanks in advance
>
> Massimo Barabino
>
>



Re: Passing parameters to constructor

Posted by Leo de Blaauw <l....@chello.nl>.
Hi all,

This brings me to an interesting related question. We have a webservice
based upon
a wsdl by a third party. Now we would like to be able to parse / use a
parameter send
on the invoking URL bij the third party who invokes our service, without
putting that
into the wsdl over wich we have litle to no controll. For example:

http://ourserver.com/axisservices/ourservice?valueOne

Anyone know if this can be done ?

Sincere greetings,

Leo de Blaauw

----- Original Message -----
From: "Thomas Bayer" <ba...@oio.de>
To: <ax...@ws.apache.org>
Sent: Monday, September 01, 2003 2:03 PM
Subject: AW: Passing parameters to constructor


> Hi Massimo,
>
> Axis is responsible for the creation of MyClass objects. So Axis creates
an
> instance of the service implementation using the newInstance() method of
> class Class. Axis expects a default constructor. Normally the Java
compiler
> generates a default constructor, but if you write your own constructor the
> Java compiler doesn't insert a default constructor.
> So you can use two constructors one default for Axis and one if you use
the
> class somewhere else. But if you want Axis to initialize your service you
> can use the init() method of the ServiceLifecycle interface and parameters
> from the wsdd file.
>
> Thomas
>
>
> WSDD:
>
> <service name="MyService" provider="java:RPC">
>   <parameter name="className" value="MyClass"/>
>   <parameter name="a" value="1"/>
>   <parameter name="b" value="2"/>
> </service>
>
>
>
> MyClass:
>
> public class MyClass implements ServiceLifecycle {
>     private int a=0;
>     private int b=0;
>
>     public void init(Object servletEndpointContext) throws
ServiceException
> {
>
>       MessageContext msgContext = MessageContext.getCurrentContext();
>
>       System.out.println("a: " + msgContext.getProperty("a"));
>       System.out.println("b: " + msgContext.getProperty("b"));
>     }
>
>     public void destroy() {
>     }
>
>     public int callMe{
>         return a+b;
>     }
>
> }
>
> > -----Ursprüngliche Nachricht-----
> > Von: Massimo Barabino [mailto:msmbarabino@virgilio.it]
> > Gesendet: Montag, 1. September 2003 13:02
> > An: axis-user@ws.apache.org
> > Betreff: Re: Passing parameters to constructor
> >
> >
> > vairamuthu thayapavan wrote:
> >
> > >hi
> > >i think u mean the ws classes in axis. for that 1st specify a default
> > >constructor with out any parameter. then specify ur constructor with
> > >required parameter.
> > >-
> > >thayapavan
> > >
> > >
> > Hi,
> > Thanks a lot for the replies.
> > Maybe I need to be more specific with what I mean as "the constructor of
> > the java class invoked by axis". Suppose my Service just consists of one
> > simple class as follows.
> >
> > public class MyClass{
> >     private int a=0;
> >     private int b=0;
> >
> >     public MyClass(){
> >         this.a=1;
> >         this.b=2;
> >     }
> >
> >     public int callMe{
> >         return a+b;
> >     }
> >
> > }
> >
> > If the constructor remains as I wrote, everithing goes OK. As I change
> > it as follows I get fault codes
> >
> > ...
> >
> > public MyClass(int a, int b){
> >         this.a=a;
> >         this.b=b;
> >     }
> > ...
> >
> > This is my problem. (may be Thomas' and your replies already apply to
> > this...)
> >
> > Thanks once again
> >
> > Massimo Barabino
> >
> >
>


AW: Passing parameters to constructor

Posted by Thomas Bayer <ba...@oio.de>.
Hi Massimo,

Axis is responsible for the creation of MyClass objects. So Axis creates an
instance of the service implementation using the newInstance() method of
class Class. Axis expects a default constructor. Normally the Java compiler
generates a default constructor, but if you write your own constructor the
Java compiler doesn't insert a default constructor.
So you can use two constructors one default for Axis and one if you use the
class somewhere else. But if you want Axis to initialize your service you
can use the init() method of the ServiceLifecycle interface and parameters
from the wsdd file.

Thomas


WSDD:

<service name="MyService" provider="java:RPC">
  <parameter name="className" value="MyClass"/>
  <parameter name="a" value="1"/>
  <parameter name="b" value="2"/>
</service>



MyClass:

public class MyClass implements ServiceLifecycle {
    private int a=0;
    private int b=0;

    public void init(Object servletEndpointContext) throws ServiceException
{

      MessageContext msgContext = MessageContext.getCurrentContext();

      System.out.println("a: " + msgContext.getProperty("a"));
      System.out.println("b: " + msgContext.getProperty("b"));
    }

    public void destroy() {
    }

    public int callMe{
        return a+b;
    }

}

> -----Ursprüngliche Nachricht-----
> Von: Massimo Barabino [mailto:msmbarabino@virgilio.it]
> Gesendet: Montag, 1. September 2003 13:02
> An: axis-user@ws.apache.org
> Betreff: Re: Passing parameters to constructor
>
>
> vairamuthu thayapavan wrote:
>
> >hi
> >i think u mean the ws classes in axis. for that 1st specify a default
> >constructor with out any parameter. then specify ur constructor with
> >required parameter.
> >-
> >thayapavan
> >
> >
> Hi,
> Thanks a lot for the replies.
> Maybe I need to be more specific with what I mean as "the constructor of
> the java class invoked by axis". Suppose my Service just consists of one
> simple class as follows.
>
> public class MyClass{
>     private int a=0;
>     private int b=0;
>
>     public MyClass(){
>         this.a=1;
>         this.b=2;
>     }
>
>     public int callMe{
>         return a+b;
>     }
>
> }
>
> If the constructor remains as I wrote, everithing goes OK. As I change
> it as follows I get fault codes
>
> ...
>
> public MyClass(int a, int b){
>         this.a=a;
>         this.b=b;
>     }
> ...
>
> This is my problem. (may be Thomas' and your replies already apply to
> this...)
>
> Thanks once again
>
> Massimo Barabino
>
>

Re: Passing parameters to constructor

Posted by Massimo Barabino <ms...@virgilio.it>.
vairamuthu thayapavan wrote:

>hi
>i think u mean the ws classes in axis. for that 1st specify a default
>constructor with out any parameter. then specify ur constructor with
>required parameter.
>-
>thayapavan
>  
>
Hi,
Thanks a lot for the replies.
Maybe I need to be more specific with what I mean as "the constructor of 
the java class invoked by axis". Suppose my Service just consists of one 
simple class as follows.

public class MyClass{
    private int a=0;
    private int b=0;

    public MyClass(){
        this.a=1;
        this.b=2;
    }

    public int callMe{
        return a+b;
    }

}

If the constructor remains as I wrote, everithing goes OK. As I change 
it as follows I get fault codes

...

public MyClass(int a, int b){
        this.a=a;
        this.b=b;
    }
...

This is my problem. (may be Thomas' and your replies already apply to 
this...)

Thanks once again

Massimo Barabino



Memory usage

Posted by Benedick Mark Chan <bm...@ntsp.nec.co.jp>.
Hello everyone,

I have a question with regards to memory usage of axis.

I have observed that for every request that  I make with the web service,
axis does not release the memory of the request made. Therefore, when I have
a lot of request made, axis keeps on eating up memory until the memory of
the server is consumed.

Is there a way to force axis to do garbage collection? By the way, my web
service's session is "request".

I am stuck. Please help me.

Your help will be greatly appreciated. Thanks.

Best regards,
Benedick