File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes File as Attachment in J2ME client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "File as Attachment in J2ME client" Watch "File as Attachment in J2ME client" New topic
Author

File as Attachment in J2ME client

lokesh jain
Ranch Hand

Joined: Feb 21, 2009
Posts: 58
hi all,
I have made a java web service. Which takes SQL query, Username and password of Database to connect to and the file name which i want to give to the created text file as parameters and it returns a text file. Now, I want to receive the same file ( stored at server side) on J2ME client side. If i make a normal Java web service client then I can get the file using DataHandler. However, I am not able to get the file as attachment using the DataHandler at J2ME client side. It said it does not recognize DataHandler, however I tried and the server side code returns the datahandler as byte[]. I tried to take the advantage and in J2ME client took the result as byte[]. But no use It is giving me Uncaught exception java/lang/NullPointerException. Can you please look into it. I am attaching the files, Server side code and the client side code and the files made as stub.
The client side code is here


The server side code is ::



Thanks in advance
Lokesh
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
If I understood you correctly, you want to download text file from server with your j2me client, and it should be response from java webservice.
Maybe this link would be helpful
http://www.java-samples.com/showtutorial.php?tutorialid=15
You can modify it to make proper ws request
lokesh jain
Ranch Hand

Joined: Feb 21, 2009
Posts: 58
hi, you are right, we can do like that. However, I need to get the file as attachment to client side, not getting the Byte Array. Is this possible that, we get the text file and store it in RMS and then read it from RMS itself??

regards
Lokesh
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
You can store anything in RMS including objects (check Floggy framework)
I'm not sure you can get anything except byte array but you can deserialize it to something useful

Are you trying to send mail with attachment?
For reading attachment you may need some j2me mail api.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File as Attachment in J2ME client