GeeCON Prague 2014*
The moose likes Web Services and the fly likes Getting Different File Sizes from the server. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Getting Different File Sizes from the server." Watch "Getting Different File Sizes from the server." New topic
Author

Getting Different File Sizes from the server.

pavan aryan
Greenhorn

Joined: Feb 28, 2010
Posts: 15
Sorry for the title. It will be a long story for my error..to be precise. I am doing a cross study between SOAP and REST and their features. Now working on Files..say client request a file from the server and server returns it. To make it more challenging and for load testing i choosen Image files. of sizes 5mb-40mb ( i developed myself using photoshop ) . So for the SOAP not to depend on SAAJ and MTOM, i followed different examples and made a custom code myself.

Coming to here, the server returns an image, i converted image to byte array and returned to client. At the Client i am storing it to files locally..now the problem I am getting files of different sizes from server (dont know problem with serverlogic or client logic). A file of 5 mb from the server , stores as 3.34mb first time and later 900 kb second time and 3.34mb again not the 5 mb. I am Using Net Beans 6.7 and Glass Fish V3 Prelude.

Server Code


Client Side Code



All this i am doing from long time, now at the time i am getting some results.. this was happening. Please Help me guys i am very very close to my deadline.
Looks like some compression is going..not gettign wether at server side or client side :'(

THanks,
Kumar
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I am not sure about the cause of your problems, but since you have rather large files, I would suggest another strategy:
- Change the return type of the atttest method to javax.activation.DataHandler.
- Do not read the file into memory, but instead use an instance of FileDataSource like this:

Hope this helps!
pavan aryan
Greenhorn

Joined: Feb 28, 2010
Posts: 15
Ivan Krizsan wrote:Hi!
I am not sure about the cause of your problems, but since you have rather large files, I would suggest another strategy:
- Change the return type of the atttest method to javax.activation.DataHandler.
- Do not read the file into memory, but instead use an instance of FileDataSource like this:

Hope this helps!



thanks Ivan Krizsan for the solution yes it is working i am having problem at client side to store locally. I am gettting the image in bytearray at client side i tried various ways to convert the bytearray to file and store locally..but the file being stored was of different file size ..i am using bytearray.length at the client side and its returning same sizes for small images...i think i am messing at the clien side...sorry for asking again..please show me a solution..the code i have been trying

Server Side


Client side



Thanks in advance,
Kumar.
pavan aryan
Greenhorn

Joined: Feb 28, 2010
Posts: 15
i fixed my problem..thanks to Ivan for major help. i just got something and opened my complete referene (took time to find it ) and got these two lines of code that fixed the problem..



 
GeeCON Prague 2014
 
subject: Getting Different File Sizes from the server.