• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileInputStream  RSS feed

 
Sara Watson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want a method in my webservice to return a FileInputStream to the caller. The caller is remote. Can I do this? I get an rmi exception.....

java.rmi.UnmarshalException: java.io.IOException: no argument constructor is missing. java.io.FileInputStream

How do I handle this?

Thanks,
Sara
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to read the contents of the stream to a byte array (or String, depending on the contents), and send that as a return value to the client. Even if you did manage to send a reference to a FileInputStream to the client (which you can't, since it's not Serializable), I wouldn't think that there would be any way for the remote client to read anything from it.
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then again, if the file is big it wouldn't be a good idea to send the contents as a response either... If you really want the client to get access to the full file you should probably consider publishing it via ftp or something like that. You could then have the webservice return information to the client on where the file can be retrieved using ftp.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!