Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending a xml file as a method parameter to a session bean

 
Megan Hill
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to send a xml file to a session bean as a parameter of a method.
How do I do it?
Thanks,
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pass the contents of the XML file as a String.
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not as InputStream?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An InputStream is not Serializable, as all EJB arguments must be. A String is.
Kyle
 
Megan Hill
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.
I will send it as a String.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hold on pardner! Just because you CAN pass an XML file as a String doesn't mean you should! In fact, I would consider this to be a REALLY BAD idea...
Think about it this way -- an EJB call is a potentially remote call. The very idea of taking an XML string (which represents object data) and passing it into an EJB to be parsed is pretty outrageous -- why incur all of that parameter passing overhead by passing all that extra stuff over the network?
Instead, I tend to lean STRONGLY towards doing all of the XML parsing on the other side of the remote interface (in the client, be it a servlet, Java application, or Message Driven Bean) and then creating a Serializable Java object (a Value Object) to hold the results and then passing that to the EJB. It fits better with the EJB architecture, and will usually be significantly faster.
Kyle
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic