It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes EJB or web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB or web service" Watch "EJB or web service" New topic

EJB or web service

sarah Marsh
Ranch Hand

Joined: Mar 06, 2001
Posts: 282
If all the code is in Java, how to decide if use web service or EJB?

sarah Marsh
Ranch Hand

Joined: Mar 06, 2001
Posts: 282
Any idea?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
EJB and WS fulfill rather different roles. They don't compete with one another, but can complement each other. E.g., you might use a WS to expose the functionality of an EJB to another system or the outside world.

If you told us the details of the scenario you're thinking of, we might be better able to advise on which might be better suited.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

If you use the EJB all the code will be in java (both server and client). If you use Web Services, only the server will be in java, the client can be anything that will send/receive XML. Also, Web Services are generally considered to be slower since there's no way to avoid serializing/deserializing the objects (which some application servers can avoid with EJBs).
[ July 10, 2008: Message edited by: Scott Selikoff ]

[OCA 8 Book] [Blog]
I agree. Here's the link:
subject: EJB or web service
It's not a secret anymore!