1 22 package org.jboss.test.webservice.samples; 23 24 import org.jboss.logging.Logger; 25 26 import javax.ejb.EJBException ; 27 import javax.ejb.SessionBean ; 28 import javax.ejb.SessionContext ; 29 import javax.naming.InitialContext ; 30 import javax.naming.NamingException ; 31 import javax.xml.rpc.Service ; 32 import java.rmi.RemoteException ; 33 34 40 public class OrganizationClientBean implements SessionBean 41 { 42 private static final Logger log = Logger.getLogger(OrganizationClientBean.class); 44 45 46 public String getContactInfoEJB(String organization) throws RemoteException 47 { 48 Service service = null; 49 try 50 { 51 InitialContext iniCtx = new InitialContext (); 52 service = (Service )iniCtx.lookup("java:/comp/env/service/OrganizationServiceEJB"); 53 Organization endpoint = (Organization)service.getPort(Organization.class); 54 String info = endpoint.getContactInfo(organization); 55 return info; 56 } 57 catch (NamingException e) 58 { 59 throw new EJBException (e); 60 } 61 catch (Exception e) 62 { 63 throw new EJBException ("Cannot invoke webservice", e); 64 } 65 } 66 67 68 public String getContactInfoJSE(String organization) throws RemoteException 69 { 70 try 71 { 72 InitialContext iniCtx = new InitialContext (); 73 OrganizationService service = (OrganizationService)iniCtx.lookup("java:comp/env/service/OrganizationServiceJSE"); 74 Organization endpoint = (Organization)service.getOrganizationPort(); 75 String info = endpoint.getContactInfo(organization); 76 return info; 77 } 78 catch (NamingException e) 79 { 80 throw new EJBException (e); 81 } 82 catch (Exception e) 83 { 84 throw new EJBException ("Cannot invoke webservice", e); 85 } 86 } 87 88 90 public void ejbCreate() 91 { 92 } 93 94 public void setSessionContext(SessionContext ctx) throws EJBException , RemoteException 95 { 96 } 97 98 public void ejbRemove() throws EJBException , RemoteException 99 { 100 } 101 102 public void ejbActivate() throws EJBException , RemoteException 103 { 104 } 105 106 public void ejbPassivate() throws EJBException , RemoteException 107 { 108 } 109 } 110 | Popular Tags |