my dog learned polymorphism*
The moose likes Web Services and the fly likes How Can I use web services for the following requirements? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How Can I use web services for the following requirements?" Watch "How Can I use web services for the following requirements?" New topic
Author

How Can I use web services for the following requirements?

Preeti Arora
Ranch Hand

Joined: Jan 26, 2007
Posts: 74
Hi,

I have a question regarding desigining of the project.
Here is brief introduction of the requirements of the project:
We are storing person and his document images in database.
The person details are entered as soon as he comes in but his images takes time to be entered into the database(as ther are scanned and then stored in database).
So there is time lag .
Now we are bulding a notification module on top of it which will send an email to subscribed users as soon as there image is
added to the database so that they can go and view it online.
There is a batch file which will run every day and check whether for subscribed users, there images has been added to
database or not.This involves lot of database interaction.
I have designed the system in normal way (using jsp,servlets,jdbc)
but I want to know if web services will be useful in
such case.Will it provide better design to my system?
Will there be any benefit of using web services in this case?
Also I am looking for learning experience by using new technology in my project.

Please suggest.
Thanks.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2921
    
    5
Originally posted by Preeti Arora:
but I want to know if web services will be useful in
such case.Will it provide better design to my system?


Based on the requirements that you have outlined there really is no need for web services ... "You aren't going to need it".

That being said there is the opportunity to expose your document images as resources for RIA clients or other programs.

For example:

Create a user account:
POST /users

View user account details:
GET /users/{username}

Modify user account
PUT /users/{username}

Delete User account
DELETE /users/{username}

Add a document image
POST /users/{username}/documents

Fetch a document
GET /users/{username}/documents/{documentId}

Update a document
PUT /users/{username}/documents/{documentId}

Delete a document
DELETE /users/{username}/documents/{documentId}

Fetch all of the users document URIs
GET /users/{username}/documents

etc.

The content-type of the data (resource representation) submitted (POST,PUT) or returned (GET) can vary with the type of client that you intend to support. Your standard program would probably prefer an XML-based representation, while a JavaScript-based RIA client would rather have a JSON-based representation. You can expose multiple types of representations through the same URI based on the accept header in the HTTP request. However it is usually best to to have a canonical URI for each representation. So you may end up with situations like

Fetch all of the users document URIs
GET /users/{username}/documents (default return content-type: application/xml; supported: application/xml, application/json)
GET /users/{username}/documents/xml (return content-type: application/xml) - i.e. canonical URI for XML-based representation for list of document URIs
GET /users/{username}/documents/json (return content-type: application/json) - i.e. canonical URI for JSON-based representation for list of document URIs

Basically the above example is a thinly disguised adaptation of the bookmarks example from Chapter 7 of RESTful Web Services (discusses a Ruby/Rails based implementation).

The article Implementing RESTful Web Services in Java discusses (a less complete version of) the bookmarks example as implemented with (JSR-311/Jersey (not ready for prime-time, though targeted for inclusion in Java EE 6). Restlet is a more mature Java-based RESTful web services framework. Plain servlets could be used to implement a resource based interface.

IBM's Project Zero makes heavy use of the REST concept for the support of RIA clients in a web-based project.

Also have a look over the links in the Web Services FAQ.
Preeti Arora
Ranch Hand

Joined: Jan 26, 2007
Posts: 74
Thanks you so much for clearing my thoughts on this, though I realized I have lot to learn.
I will do more research to make a better design of the system.
I want to learn a step ahead from jsp,servlets etc.

Thanks again.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2921
    
    5
Originally posted by Preeti Arora:
I will do more research to make a better design of the system.


You did catch this

Originally posted by Peer Reynders:
Based on the requirements that you have outlined there really is no need for web services ... "You aren't going to need it".


right?

I wasn't implying that you needed resource-based web services. KISS principle.

There are anecdotal accounts that resource-based design principles (applied internally to the web application) may reduce complexity in some situations (Scott Raymond: Refactoring to REST; (related Rails Actions are bundled on Rails ActionControllers. Rails Actions are roughly equivalent to Struts Actions. Ruby on Rails and J2EE: Is there room for both?)).
[ February 07, 2008: Message edited by: Peer Reynders ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How Can I use web services for the following requirements?
 
Similar Threads
using servlets or ejb
to use ejb or to use servlets
How Should I approach?
Where to store the user credentials in an enterprise application(EAI)
General IS-A, Has-A relationships. Class Designing