On 6/16/06, Dennis Sosnoski <[EMAIL PROTECTED]> wrote:
robert lazarski wrote:
> <snip>
> Currently I'm integrating an EJB app with Axis2 - thankfully as any
> tomcat / servlet container web layer would. However, I came very close
> to having to implement these services as EJB, which would have
> required either JAX-WS or Axis 1.x , as Axis2 just isn't an option.
>
>
I'm puzzled by this statement, Robert. Why is Axis2 not an option? You
just use the EJB interfaces to access the service classes, same as any
other application using the EJBs.

  - Dennis

 

I'm not 100% sure we are on the same page, so allow me to give an example - in JBoss 4.0.x using JSWDP databinding and axis 1.x - a strange hybrid but that's what JBoss supports:

<enterprise-beans>
  <session>
    <ejb-name>MyWebService</ejb-name>
    <ejb-class>org.MyWebService</ejb-class>
    <session-type>Stateless</session-type>
    <ejb-ref>
        <!-- SoapSession is a stateful session bean -->
        <ejb-ref-name>ejb/SoapSession</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>org.SoapSessionHome</home>
        <remote>org.SoapSession</remote>
    </ejb-ref>
    ...
   <session>
 </enterprise-beans>
 
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class MyWebService implements SessionBean {

    private SessionContext ctx;
   
    public ReturnWeb_Login web_Login(
                        String user_name,
                        String user_password) throws RemoteException {

                Integer successErrorCode = Messages_Codes.FAILURE;
                String soap_session_id  = null;
                Connection con = null;

                try {
                       con = getConnection();
                       successErrorCode = CallCentreDAO.login(con, call_centre_id,
                                 user_name, user_password, this);

                       if(Messages_Codes.SUCCESS == successErrorCode) {
                         SoapSession soapSession = serviceLocator.getSoapSessionHome().create();
                         soapSession.setTimestamp( Calendar.getInstance() );
                         soap_session_id = serviceLocator.getSoapSession_Id(soapSession);

                       } else {
                         successErrorCode = Messages_Codes.AuthorizationFailed;
                       }
                } catch(Exception ex) {
                        ctx.setRollbackOnly();
                        successErrorCode = Messages_Codes.FAILURE;
                } finally {
                        if(con!=null)
                                try{con.close();}catch(SQLException ex){};
                }

                return new ReturnWeb_Login ( Messages_Codes.get(successErrorCode), successErrorCode.intValue(), soap_session_id, user_name);
}

So what this does is allow EJB transactions in a web service - notice  ctx.setRollbackOnly() ,  and a soap session managed by the EJB container via a stateful session bean.

OK, so why can you _not_ do this with Axis2 ?

1) JBoss modified axis 1.x to support ejb transactions:

http://wiki.jboss.org/wiki/Wiki.jsp?page=WebServiceStacks

JBossWS4EE is J2EE-1.4 compliant and available starting from jboss-4.0.0. It relies on a modified version of axis-1.1. This stack should no longer be used.

2) JBoss now is pushing JBossWS, based seemingly largely - but not entirely - on JAX-WS. Its spec support and completion status are here:

http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossWSSpecStatus

3) Most importantly: "Any stack not listed above is not supported."

So just to be clear: You can use Axis2 with EJB just fine as long as you do not want to have the ServiceClass implement SessionBean - this is at least true for JBoss. I think everyone agrees you can invoke an EJB anywhere anytime in any container as any web layer class would.

Now it would be interesting to try to implement the scenerio above with JBoss and Axis2 since the sources are open. However, (A) It'd be a labor of love and I just don't see feel it (B) JBoss is GPL and axis2 is Apache licenesed of course, and (C)  It'd be unsupported by JBoss and even if it did work, the sanity of such a scenerio is rightfully questioned by sanjiva and many others.

Cheers,
Robert
http://www.braziloutsource.com/

Reply via email to