1 4 package org.objectweb.jonas.jtests.beans.wsclient; 5 6 7 8 import java.rmi.RemoteException ; 9 import javax.ejb.CreateException ; 10 import javax.ejb.SessionBean ; 11 import javax.ejb.SessionContext ; 12 import javax.naming.InitialContext ; 13 import javax.naming.NamingException ; 14 import javax.xml.namespace.QName ; 15 import javax.xml.rpc.Call ; 16 import javax.xml.rpc.Service ; 17 import javax.xml.rpc.ServiceException ; 18 import org.objectweb.jonas.common.Log; 19 import org.objectweb.util.monolog.api.BasicLevel; 20 import org.objectweb.util.monolog.api.Logger; 21 22 23 26 public class WsClient1SLR implements SessionBean { 27 28 static private Logger logger = null; 29 SessionContext ejbContext; 30 31 Service service; 32 33 37 38 public void setSessionContext(SessionContext ctx) { 39 if (logger == null) { 40 logger = Log.getLogger("org.objectweb.jonas_tests"); 41 } 42 logger.log(BasicLevel.DEBUG, ""); 43 ejbContext = ctx; 44 } 45 46 47 public void ejbRemove() { 48 logger.log(BasicLevel.DEBUG, ""); 49 } 50 51 52 public void ejbCreate() throws CreateException { 53 logger.log(BasicLevel.DEBUG, ""); 54 } 55 56 public void ejbPassivate() { 57 logger.log(BasicLevel.DEBUG, ""); 58 } 59 60 public void ejbActivate() { 61 logger.log(BasicLevel.DEBUG, ""); 62 } 63 64 68 public boolean lookupServiceJNDI() { 69 logger.log(BasicLevel.DEBUG, "lookupServiceJNDI"); 70 service = null; 71 try { 72 InitialContext ic = new InitialContext (); 73 service = (Service ) ic.lookup("ws/XMethodsService"); 74 } catch (NamingException ne) { 75 logger.log(BasicLevel.ERROR, "looking ws/XMethodsService : " + ne.getMessage()); 76 return false; 77 } 78 return (service != null); 79 } 80 81 public boolean lookupServiceName() { 82 logger.log(BasicLevel.DEBUG, "lookupServiceName"); 83 service = null; 84 try { 85 InitialContext ic = new InitialContext (); 86 service = (Service ) ic.lookup("java:comp/env/service/XMethods"); 87 } catch (NamingException ne) { 88 logger.log(BasicLevel.ERROR, "looking java:comp/env/service/XMethods : " + ne.getMessage()); 89 return false; 90 } 91 return (service != null); 92 } 93 94 public void getAllServiceNames() throws ServiceException , RemoteException { 95 logger.log(BasicLevel.DEBUG, "getAllServiceNames"); 96 97 lookupServiceName(); 98 Call call = service.createCall(new QName ("XMethodsQuerySoap"), 99 new QName ("getAllServiceNames")); 100 call.invoke(new Object [] {}); 101 102 logger.log(BasicLevel.DEBUG, "Call is OK"); 103 } 104 } 105 106 | Popular Tags |