aspose file tools*
The moose likes Web Services and the fly likes Web service's singleton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web service Watch "Web service New topic
Author

Web service's singleton

Larry Darrell
Greenhorn

Joined: Nov 13, 2009
Posts: 3
Hello Ladies and Gents,

A bit of help please.

I have been asked to expose an application as a web service.
I used axis1 as the SOAP engine and tomcat as the container to create a wsdl and convert the app into a service.

Now, my application had a few auxiliary class implemented as singleton.
Given that the app now runs into a container, I would like to off load them onto a start up class that tomcat/axis provides.
However, owing to my limited knowledge of web services (my expertise is in core java), I can't seem to figure out how.

Any hints, tips would be much appreciated.

Cheers
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
First of all, is it a requirement to use Axis 1? If not, do try something more recent, like Axis 2, Metro, etc.
Second, as far as I understand, you have some classes providing some kind of services that are to be singletons. Are these classes to be used both by the web service and the application at the same time or are you converting the application to become a web service? What kind of services/functionality do these classes supply?
Depending on the answer of the above questions, there are different approaches available.
- If you are converting the application to become a web service, then you may consider using some kind of dependency injection framework and inject the singleton into all classes/components that are to use it.
- If you will have both a web service running in a container and a standalone-application that both requires access to one or more singleton services, then I would consider exposing these classes as services too, not available outside of your domain (consisting of the web application and the standalone-application).
Depending on what these internally used services do, you may consider using RESTful web services, RMI, etc etc to talk to them.

On a side note, if you are to expose some kind of service, then you do not necessarily have to use a container. If the service is RESTful, then you may want to consider the RESTlet framework, which will allow you to start a RESTful web service without running in a container. It is also very suitable if you have limited experience with web services.
Best wishes!
Larry Darrell
Greenhorn

Joined: Nov 13, 2009
Posts: 3
Thank you Ivan.

No, I am quite at my liberty to choose the soap engine. I chose Axis1 as it was what I discovered first on google.
And using the Axis eclipse plug-in, it was easy to create a wsdl and convert the app to a web service.

"Second, as far as I understand, you have some classes providing some kind of services that are to be singletons. Are these classes to be used both by the web service and the application at the same time or are you converting the application to become a web service?"

Yes, the latter. I am converting the application to a web service.

What kind of services/functionality do these classes supply?
The singletons provide DB connections, RMI connection, Authentication, Validation Facotry etc

"If you are converting the application to become a web service, then you may consider using some kind of dependency injection framework and inject the singleton into all classes/components that are to use it."

The only dependency injection framework I am mildly familiar with is Spring.
So do you suggest that I convert my web service to a spring ws?

Once again, thanks for your comments.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Larry Darrell wrote:
The only dependency injection framework I am mildly familiar with is Spring.
So do you suggest that I convert my web service to a spring ws?

No, there is no need for that (if you have time and interest, then feel free ), but I would suggest that you set up those singleton services as Spring beans and, instead of making them globally available in your program, inject them into the classes/components that need to use them.
Again, do consider switching to at least Axis 2. Axis 1 has, as far as I know, no support for the more recent JAX-WS standard - its focus is on JAX-RPC. This is good and well if you have requirements forcing you to use Axis 1, but if you are developing new web services with Axis 1, I fear you may paint yourself into a corner.
Best wishes!
Larry Darrell
Greenhorn

Joined: Nov 13, 2009
Posts: 3
Thanks Ivan, you have been most helpful.
I will give your suggestions a go.

Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web service's singleton