*
The moose likes Web Services and the fly likes Axis2 question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 question" Watch "Axis2 question" New topic
Author

Axis2 question

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

In Eclipse 3.6.1-SR1, if I have 2 constructors in my service class and then create a new Web Service Client using Axis2, will the stub account for the 2 constructors?

Any help/direction would be appreciated.

Regards.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
The service class should have just one constructor - it's public, and takes no parameters. How would any other constructors be called? What's more, constructors are not part of the WSDL. Maybe we're talking about different things?


Ping & DNS - my free Android networking tools app
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Ulf, thanks for the reply. I have an additional constructor that is called for my DAO code and I don't have any idea how to call that if it is not in the stub? Being a newbie to Web Services, can you please give me some direction here?

Again, your reply is appreciated. Regards.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
What do you mean by "called for my DAO code"? The DAO code wouldn't call the web service class; maybe the web service class calls the DAO code.

But again, constructors are not part of the WSDL - the web service engine uses the no-argument constructor to instantiate the web service class; no other part of the software should be using (or instantiating) the web service class. The methods of the service class are then called via the web service operations (which are listed in the WSDL).

Maybe you can provide some more detail on why and how you intend to use constructors.
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Sorry, I meant to say that I needed the 2nd constructor set by the web service and that the constructor has a parameter. If the WSDL web service engine uses the no-argument constructor what can I use to call the DAO constructor? Again, thank you very much for any help/direction. Regards.

Here is my service class:



Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
There will not be another constructor, period. Or, to be more precise, you can put one there, but it won't get used. Your code is not in charge of instantiating service classes - the WS engine is, and it will use the no-argument constructor.

What it looks like is that the service class needs a DAO object to do its work. Since you can't pass it in via a constructor, you need to find some other way to do so. Maybe the service class could call a static factory method that retrieves the object (assuming that DAO objects are thread-safe and can be reused):

If DAOs are not threadsafe, or can't be reused, you need to get a new one each time:
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Ulf, thanks again for the help/clarification on how this works. I will try what you've suggested and see if that works. If you don't mind one additional question. If I add another method, like validatingUserID and validateNECCode, etc how can I update the web service client and the WSDL that is in my Eclipse dynamic web project?

Again, thank you for your help. Regards.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
I'm not an Eclipse user, so I can't help with that. I would expect the Axis plugin (or SOAP plugin, or whatever it is) either to regenerate the WSDL automatically whenever it detects changes to the service class, or there to be a menu option to regenerate the WSDL.
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Thanks.
sweety kamal
Greenhorn

Joined: Feb 04, 2011
Posts: 4
Right click on project ->select webservices regenertae client and server again and it will automatically generate the rest of the thing
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Thanks. I appreciate the reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis2 question
 
Similar Threads
Webservices in java
Jax-ws and apache axis
axis2
ClassNotFoundException: org.apache.axis2.transport.SimpleAxis2Server
How to implement a webservice in my application?