Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stateless session bean and web service

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused in the relationship b/w web service and stateless session bean.

A stateless session bean can be a client of web service? Or A stateless session bean can be a web service? And other client can access it like web service?

Please put some more information about both.

Thanks.
 
eduardo ferreira
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ankur rathi:
I am confused in the relationship b/w web service and stateless session bean.

A stateless session bean can be a client of web service? Or A stateless session bean can be a web service? And other client can access it like web service?

Please put some more information about both.

Thanks.


Yes, yes, and yes. But when you use web services instead of IIOP to access a SLSB you lose some infrastructure services like transaction propagation.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by eduardo ferreira:


Yes, yes, and yes. But when you use web services instead of IIOP to access a SLSB you lose some infrastructure services like transaction propagation.


Thanks Eduardo.

Can you explain little bit more about this line: "But when you use web services instead of IIOP to access a SLSB you lose some infrastructure services like transaction propagation."

I searched but didn't understand it.

Thanks.
 
Nagendra Inuguri
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion, SLSB can still run under a container transaction. But it cannot propagate client's transaction to the bean.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur,

you can transform a session bean into a web service, just annotate your session bean with the @WebService annotation.
 
eduardo ferreira
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ankur rathi:

Can you explain little bit more about this line: "But when you use web services instead of IIOP to access a SLSB you lose some infrastructure services like transaction propagation."

I searched but didn't understand it.


When using container-managed transactions, you set attributes to define the transaction type of the method. When using any of the following:
# Required
# Mandatory
# Supports
If the caller has a transaction, it will be bound to the transaction used on this method (so if the caller's transaction rolls back the client transaction will roll back also). If the caller is remote, the only way for this to work is if the protocol being used is IIOP.

So, when using an EJB to expose a web service, you should think that it's methods should have only "requires new" or "not supported" transaction behavior.
 
Julio Viegas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nagendra Inuguri:
In my opinion, SLSB can still run under a container transaction. But it cannot propagate client's transaction to the bean.


If BMT is applied, and the client is a JEE container(including the client container, from the four types of containers), yes it can!

In CMT scenario, only SLSB(as client) can do it.

Rgrds,
JV
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic