How to Invoke an SDO-Enterprise JavaBeans Service
To invoke an SDO - Enterprise JavaBeans service from Enterprise JavaBeans, you must use the client library. Follow these guidelines to design an Enterprise JavaBeans client.
-
Look up the
SOAServiceInvokerBeanfrom the JNDI tree. -
Get an instance of
SOAServiceFactoryand ask the factory to return a proxy for the Enterprise JavaBeans service interface. -
You can include a client side Enterprise JavaBeans invocation library (
$FMW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/fabric-client.jaror thefabric-runtime.jarfile located in the Oracle JDeveloper home directory or Oracle WebLogic Server) in the Enterprise JavaBeans client application. For example, thefabric-runtime.jarfile can be located in theJDev_Home\jdeveloper\soa\modules\oracle.soa.fabric_11.1.1directory.If the Enterprise JavaBeans application is running in a different JVM than Oracle SOA Suite, the Enterprise JavaBeans application must reference the
ejbClientlibrary. The code that follows provides an example.You must specify the complete path of the service ID with the
MyTestEJBServiceparameter ofserviceFactory.createService(for example,"default/MyTestProject!1.0/MyTestEJBService"). If the complete path is not specified, you receive anEJBException-Couldnot locatetheserviceerror.
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL, "t3://" + HOSTNAME + ":" + PORT);
InitialContext ctx = new InitialContext(props);
SOAServiceInvokerBean invoker =
(SOAServiceInvokerBean)
ctx.lookup("SOAServiceInvokerBean#oracle.integration.platform.blocks.sdox.ejb.api.
SOAServiceInvokerBean");
//-- Create a SOAServiceFactory instance
SOAServiceFactory serviceFactory = SOAServiceFactory.newInstance(invoker);
//-- Get a dynamice proxy that is essentially a remote reference
HelloInterface ejbRemote =
serviceFactory.createService("complete_path/MyTestEJBService", HelloInterface.class);
//-- Invoke methods
Item item = (Item) DataFactory.INSTANCE.create(Item.class);
item.setNumber(new BigInteger("32"));
SayHello sayHello = (SayHello)
DataFactory.INSTANCE.create(SayHello.class);
sayHello.setItem(item);
SayHelloResponse response = ejbRemote.sayHello(sayHello);
Item reply = response.getResult();