• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File as Attachment in J2ME client

 
lokesh jain
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic