I am currently reworking a legacy JAVA data driven web application to a MVC model. While reworking, I realized that almost all servlets call a getID() method and almost 10 other methods. I am thinking of converting these method calls to a service. This would be my first web service development. I use Eclipse and weblogic. While I am reading up online, can someone give me a brief outline of how this can be achieved to get a head start? Another question is, do these services get invoked from a business class or a servlet or a jsp or from all of these? Thanks.
Share
Web service can mean XML-RCP, SOAP, or REST. To me, web service means “calling a networked component via HTTP.” If you agree, you can simply refactor those methods into another servlet and call it a service.
Don’t use XML request/response unless you need to.
I would not invoke services from business classes. Servlets and JSPs are firmly in the web tier, so I can both calling a web service (e.g. AJAX calls from a page).
But my preference would be to have a true service layer, with services calling services. The service layer is more reusable than it’ll be if you embed that stuff in the web tier. What happens to all that code if you go with a mobile UI? The web tier should validate and bind input parameters, call services to fulfill the use case, and package up the response for display. Let the services do the heavy lifting.