It's not a secret anymore!*
The moose likes Web Services and the fly likes Sending only 1mb of files from folder through web service. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Sending only 1mb of files from folder through web service." Watch "Sending only 1mb of files from folder through web service." New topic
Author

Sending only 1mb of files from folder through web service.

Shashank Acharya
Greenhorn

Joined: Mar 20, 2010
Posts: 21

Hello All,

My question is that I want to send pdf files through web service with condition that only 1mb of files are taken from that folder containing many files.

Please help me to resolve this question.I am new to web service.
Ask me again if it not clear.
Thanks In Advance.
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
Write you plain java logic to solve your problem. Expose you code as webservice with the help of java2wsdl.


SCJP 1.5(97%) My Blog
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
It sounds like a RESTful web service could be a good fit for you. I am not entirely sure I have understood all of your requirements, but I'll make an attempt:
Lets assume all your documents are found under the /documents resource.
If a client performs a GET on the /documents resource root, then a list of PDF documents adhering to your size requirement is produced with URIs to each document in the list.
If the client performs a GET on a specific /documents resource, then the appropriate PDF document is downloaded.
Please do not hesitate to ask if I have been unclear!
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Shashank Acharya
Greenhorn

Joined: Mar 20, 2010
Posts: 21

Hi Ivan,shivendra

@shivendra I wrote a plain logic for it & my eclipse ide has made fine wsdl for me.

@Ivan I am using Apache Axis web service for it. My question is that I want to collect files of total 1 mb from specific folder.

Here is my code to retrieve that. I am easily getting that.



Now my question is
1. If the web service is called how can I know that it first call or second call.i.e if when server has started first time the web service is called,if after some time web service is called second time how can I track that.
2. How to track that this many files are send to client & next are remaining.i.e if in first call I send total of 4 files(having 1 mb of size),then in second call I have to send files from 5th file upto my required size.


Can you please help in this.

Please ask me if it not clear.
Thanks for reply.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Since you are already using the file system, you can use lock file(s).
Files can be created atomically using File.createNewFile() and you can use some appropriate naming scheme to be able to make the decisions you need to make.
Best wishes!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sending only 1mb of files from folder through web service.