• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web service's singleton

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ivan, you have been most helpful.
I will give your suggestions a go.

Thanks again.
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic