I have a typical scenerio for creating a Webservice on the top of existing Web application. I am facing problem related to designing the application. Since I cannot post the exact Business Details or Framework/api due to copyright issue [;)] I am putting a scenerio which I guess many people like me might have faced earlier.
I need to expose a WebService that returns List of Products(just the product id and name to be specific). That I need to fit into my existing application framework I am currently using.
- An MVC Web application
- Its a Struts-Spring-Hibenate based customized framework
- It contains Action Classes that handles the UI interaction.
- A layer containing Service Classes that handles the business logic.
- A layer containing DataMapper Classes to interact with database.
- There are also ApplicationContext that contains common objects needed throughout the application.
- Then there are ServiceContext that is tied with Service Classes to store objects during the service lifecycle.
So if I have a list of Products page it will work like this:
Project JSP-> ProductAction-> ProductService-> ProductDataMapper.
ProductService(Not a webservice) can return list of Products from a copy of Product from ProductContext or it will load it from ProductDataMapper and update the ProductContext if used for the first time.
ProductService, its Context and DataMappers are Injected through Spring.
Now these Services(Non Webservice) and associated classes are stored in Spring Applications Context(the object scope being session) AND there are other objects that are located in Web Application Context
Now If I create a web service in Axis
I just write a plain POJO and using that I will be returing list of products.
- GetListOfProducts(): List
Rest of the things are hidden by the Axis Webservice API...
So In my ProductWebService call I cannot use or access Information/Classes already loaded in the webapplication.
Allthough I can use Spring to create and load above mentioned classes. But then I have to reload data that are common throughout the web application. For Ex: We have Some Authentication mechanism in our application and the web application stores the userinformation in Session. and I need to display only that list of product the logged in User have permissions.
How do I architect such Web Service, Since I only have POJO class in my control...
Am I doing some thing wrong or if this is a issue with Axis...
Can my problem be resolved using any other WS API?