package org.jboss.test.webservice.samples;
import org.jboss.logging.Logger;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.xml.rpc.Service;
import java.rmi.RemoteException;
public class OrganizationClientBean implements SessionBean
{
private static final Logger log = Logger.getLogger(OrganizationClientBean.class);
public String getContactInfoEJB(String organization) throws RemoteException
{
Service service = null;
try
{
InitialContext iniCtx = new InitialContext();
service = (Service)iniCtx.lookup("java:/comp/env/service/OrganizationServiceEJB");
Organization endpoint = (Organization)service.getPort(Organization.class);
String info = endpoint.getContactInfo(organization);
return info;
}
catch (NamingException e)
{
throw new EJBException(e);
}
catch (Exception e)
{
throw new EJBException("Cannot invoke webservice", e);
}
}
public String getContactInfoJSE(String organization) throws RemoteException
{
try
{
InitialContext iniCtx = new InitialContext();
OrganizationService service = (OrganizationService)iniCtx.lookup("java:comp/env/service/OrganizationServiceJSE");
Organization endpoint = (Organization)service.getOrganizationPort();
String info = endpoint.getContactInfo(organization);
return info;
}
catch (NamingException e)
{
throw new EJBException(e);
}
catch (Exception e)
{
throw new EJBException("Cannot invoke webservice", e);
}
}
public void ejbCreate()
{
}
public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException
{
}
public void ejbRemove() throws EJBException, RemoteException
{
}
public void ejbActivate() throws EJBException, RemoteException
{
}
public void ejbPassivate() throws EJBException, RemoteException
{
}
}