• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pass the contents of the XML file as a String.
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why not as InputStream?
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies.
I will send it as a String.
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic