Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web services is replacement for EJB

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I say web services is replacement for EJB?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NO
 
Jair Rillo Junior
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No!!
Both have different purpose, although you can use Webservice plus EJB3 in an easy way.

I have been using WebService + EJB3 + JMS together in the same project successfully
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you reply,sorry for asking this again,I read a some article,in that given as "EJB is a server component deployed in different JVMs.So Instead of accessing the EJB thru RMI,EJB can be implemented as web services in remote machine and used in my application.So here No role of EJB."

Please correct me if i am wrong
 
Jair Rillo Junior
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jacob deiter:
Thanks for you reply,sorry for asking this again,I read a some article,in that given as "EJB is a server component deployed in different JVMs.So Instead of accessing the EJB thru RMI,EJB can be implemented as web services in remote machine and used in my application.So here No role of EJB."

Please correct me if i am wrong


That's true. If you have an EJB3 component and want to expose it as Webservice, only use an annotation @Webservice, it is really simple. However, when you access an EJB through Webservice you will loose performance, because Webservice uses HHTP/SOAP protocol and EJB itself uses RMI-IIOP (it's much faster than SOAP)
 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jacob,
Let's take a step back here. A service is a piece of functionality. The service must be implemened and EJB is a means to implement the service. This service can be consumed by
1. A java consumer using ejb client jar over RMI-IIOP
2. Any consumer using web service client over SOAP-HTTP

If you expose something as a web service, it just means that the service can be invoked using SOAP/HTTP but the role of implementation doesn't go away. If you take the EJB out, who will execute the logic of the service?

If you are thinking EJB allows a client in a remote JVM to invoke a service, similarly, web service allows a remote client to invoke a service so you don't need EJB, you are right (and wrong). You don't need EJB from remote access perspective. You can use a POJO (Plain Old Java Object) and expose it as a web service and access it remotely. However, if you don't use EJB, you loose container provided functionality such as role based security, transactions etc. Also, plain java call runs faster than EJB runs faster than web service. So, for performance reasons you may decide to stick with EJB as opposed to web services.

Lately, alternative approaches like servlet based web service and spring container supported POJO based web service are becoming popular. They don't suffer from some of the disadvantages of EJBs. On the other end of the spectrum there are also concepts like REST-ful services, which can use JSON format making the web service perform even better (JSON is an alternative to XML. It reduces the overhead of XML processing).

So, to summarize, EJB isn't needed from remote access perspective but they may be needed based on other requirements. Hope this helps...
 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all!!!.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic