Dynamic Invocation Of EJB's ?

I am intending to write a dispatcher class that takes the name of an EJB at
runtime and then looks up and invokes a method on the EJB. I was intending
to
create a simple interface that the EJB will implement something like:-
public interface DynamicEJBDef
public void dynamicMethod() throws Exception;
The dynamic method would be implemented in the Bean class and thus the
Remote class.
Then to invoke I was thinking of something like the following:-
String ejbJNDIName = "testEJB";
EJBHome ejbHome = (EJBHome) ctx.lookup(ejbJNDIName);
DynamicEJBDef ejbObj = (DynamicEJBDef) ejbHome.create();
ejbObj.dynamicMethod();
Has anyone done this before ? Will it work and if not any other
suggestions...?
TIA

We did this a couple of year ago with a servlet that called a
'GenericRequestHandler' class. The servlet was passed an xml message in the
request that had a header that contained the request type. The data for the
request was in a body portion of the xml message. We used the information in
the header to call a request handler factory class that returned a request
handler that would deal with the message type. Most of the time, if the request
was generic enough, it returned the 'GenericRequestHandler'. If the request was
more complex, the factory would return a specific request handler. The request
handler classes all implemented the same interface and used the header info to
map to a jndi lookup of an entity ejb, and a call to an appropriate method on
the entity ejb. It was great if all of the requests were of a generic nature.
Kind of a poor man's SOAP request.
The hassle was parsing all the xml and figuring out what to do in the factory,
as well as, writing the specific request handlers when the requests got more
complex. The specific request handlers got pretty involved.
I don't have access to the code....and if I did I couldn't give it to you....or
they would kill me. ;-)
But, it worked.
Bill
Martin J Porter wrote:
I am intending to write a dispatcher class that takes the name of an EJB at
runtime and then looks up and invokes a method on the EJB. I was intending
to
create a simple interface that the EJB will implement something like:-
public interface DynamicEJBDef
public void dynamicMethod() throws Exception;
The dynamic method would be implemented in the Bean class and thus the
Remote class.
Then to invoke I was thinking of something like the following:-
String ejbJNDIName = "testEJB";
EJBHome ejbHome = (EJBHome) ctx.lookup(ejbJNDIName);
DynamicEJBDef ejbObj = (DynamicEJBDef) ejbHome.create();
ejbObj.dynamicMethod();
Has anyone done this before ? Will it work and if not any other
suggestions...?
TIA

Similar Messages

  • Setting the charset in dynamic invocation

    I'm on WLS 8.1 SP1. The doc (http://e-docs.bea.com/wls/docs81/webserv/i18n.html)
    shows how to set the charset attribute of the Content-Type HTTP header via the
    client stub. But I am not using client stubs, I'm using dynamic invocation. So
    how do I accomplish the equivalent? I don't see an obvious javax.xml.rpc.Call
    property field for this.
    TIA...
    Mark

    The trouble with this example is that it doesn't use JAX-RPC dynamic invocation.
    The attachment contains an example of what I am trying to do. The method of interest
    is case3(), in which. on lines 294-296, is an (unsuccessful) attempt to set the
    character set. The other methods of interest here are getEMAExceptionServices()
    (which creates the javax.xml.rpc.Service object) and getUpdateExceptionResolutionStatusCall(Service
    iService) (which creates the javax.xml.rpc.Call object).
    [OK, this time I attached something.]
    -- Mark --
    Bruce Stephens <[email protected]> wrote:
    Hi Mark,
    Take a quick look at Manoj's Mega example [1] and see if this clears
    things up. If not, post your code and we can take a look, or speak to
    our outstanding support team: http://support.bea.com or [email protected]
    Thanks,
    Bruce
    [1]
    http://manojc.com/tutorial/mega/client/BindingProperties.java
    Mark Shaffer wrote:
    Bruce,
    If I try to get the "weblogic.webservice.bindinginfo" property froma Call object,
    this exception is thrown:
    javax.xml.rpc.JAXRPCException: unknown property: weblogic.webservice.bindinginfo
    at weblogic.webservice.core.rpc.CallImpl.getProperty(CallImpl.java:322)
    -- Mark --
    Bruce Stephens <[email protected]> wrote:
    Hi Mark,
    Did you try the code in the doc?
    import weblogic.webservice.binding.BindingInfo;
    BindingInfo info =
    (BindingInfo)stub._getProperty("weblogic.webservice.bindinginfo" );
    // The following method sets the Content-Type HTTP header
    info.setCharset( "UTF-8" );
    port.helloWorld();
    Thanks,
    Bruce
    Mark Shaffer wrote:
    Bruce,
    OK, but the disconnect here is that I don't have a BindingInfo object,nor do
    I know how to obtain one. All I have is javax.xml.rpc.* objects.
    -- Mark --
    Bruce Stephens <[email protected]> wrote:
    Hi Mark,
    Your client application can specify the character set that it would
    prefer the Web Service to use in its response by using the
    weblogic.webservice.binding.BindingInfo.setAcceptCharset() method.
    See: http://e-docs.bea.com/wls/docs81/webserv/i18n.html#1069629
    There is example code there as well.
    Hope this helps,
    Bruce
    Mark Shaffer wrote:
    I'm on WLS 8.1 SP1. The doc (http://e-docs.bea.com/wls/docs81/webserv/i18n.html)
    shows how to set the charset attribute of the Content-Type HTTP
    header
    via the
    client stub. But I am not using client stubs, I'm using dynamic
    invocation.
    So
    how do I accomplish the equivalent? I don't see an obvious javax.xml.rpc.Call
    property field for this.
    TIA...
    Mark
    [UTEMAExceptionServices.java]

  • Problem with Dynamic Invocation of Webservice

    Hi,
    I am trying to use Dynamic Invocation Of Webservice, as defined in the following link .
    "http://download.oracle.com/docs/cd/B14099_19/web.1012/b14027/xhtmlstrm.htm#i1010275"
    I have written standalone java client program to invoke, while invoking i got the error as follows :
    Exception in thread "main" java.lang.NoSuchFieldError: FAULT_CODE_IOEXCEPTION
         at oracle.soap.transport.http.OracleSOAPHTTPConnection.send(OracleSOAPHTTPConnection.java:765)
         at org.apache.soap.rpc.Call.invoke(Call.java:248)
         at oracle.ds.v2.impl.adaptor.protocol.soap.DsSoapRpcHandler.execute(DsSoapRpcHandler.java:93)
         at oracle.ds.v2.impl.adaptor.protocol.soap.DsSoapHandler.execute(DsSoapHandler.java:130)
         at oracle.ds.v2.impl.adaptor.protocol.soap.DsSoapProtocolAdaptor.process(DsSoapProtocolAdaptor.java:134)
         at oracle.ds.v2.impl.engine.ProtocolManager.process(ProtocolManager.java:69)
         at oracle.ds.v2.impl.engine.DefaultManagerExecutionContext.executeProtocolAdaptor(DefaultManagerExecutionContext.java:382)
         at oracle.ds.v2.impl.adaptor.execution.DummyExecutionAdaptor.process(DummyExecutionAdaptor.java:54)
         at oracle.ds.v2.impl.engine.ExecutionManager.process(ExecutionManager.java:393)
         at oracle.ds.v2.impl.engine.ExecutionManager.doExecute(ExecutionManager.java:348)
         at oracle.ds.v2.impl.engine.ExecutionManager.execute(ExecutionManager.java:259)
         at oracle.ds.v2.impl.connection.DefaultDsConnection.execute(DefaultDsConnection.java:162)
         at oracle.j2ee.ws.client.impl.DefaultWebServiceMethod.execute(DefaultWebServiceMethod.java:192)
         at oracle.j2ee.ws.client.impl.DefaultWebServiceMethod.invoke(DefaultWebServiceMethod.java:160)
         at com.sub.atl.dynamicws.DynamicWS.wsdlDetails(DynamicWS.java:102)
         at com.sub.atl.dynamicws.DynamicWS.main(DynamicWS.java:19)
    Can, any one help to solve this error.

    What does your code look like?
    By the error it appears you are trying to access a field called "FAULT_CODE_IOEXCEPTION" which doesn't exist.

  • Dynamic update of EJB/Web deployment descriptors

    In 8.1SP3, is there any provision to allow for dynamic update of EJB/Web deployment descriptors? I'm specifically looking at env var changes.
    I noticed that there are some mentions of the ability to dynamically update deployment descriptors, but it appears that the general facility has been deprecated, and they've incorporated all of the WebLogic-specific descriptor information directly into the console.
    When I dig through the JMX namespace and some of the MBean classes, I also see mentions of "deployment descriptor editors", but it's not clear how to utilize that.
    I'm aware of the fact that my application would have to be aware of possible dynamic updates to the descriptors, so I'd have to be able to implement some sort of listener for that.

    I have the same question but for a different purpose. I am part of a hosting group and we have app teams that have defined init-params in the web.xml that have to be changed as the app is promoted up through test environments and ultimately to production - only we need to be able to do this WITHOUT "cracking open" the archive.
    I was hoping to be able to script something to do the update after deployment.
    So any help at all would be appreciated. In the meantime will continue to poke around in the WLST and MBean docs.
    Thanks,
    Ed

  • Web Services Dynamic Invocation

    Hi,
    I am trying to find a way to do web services dynamic invocation where params and return type can be complex types.
    The process I intent to follow is, query a uddi registry based on some search criteria to get a reference to the service wsdl. Use maybe wsdl4j to introspect the wsdl to determine porttype, operations, param data types etc and then perform a dynamic invocation.
    Does anybody have any ideas on how best this can be achieved without having to reinvent the wheel.
    Thanks,
    -V

    Hi
    I am looking for the same thing, please let me know if you resolve it.
    thanks

  • Dynamic invocation in Axis

    I've deployed two services, one using framework Axis, one using framework Muse(a web service apache project).
    I want to make a dynamic invocation from Axis to use an operation of Muse, I add the code in the impl document of Axis. Is it possible to do that?
    Thank you in advance.

    first of all, you are invoking the webservice with a string, not with xml.
    secondly, ditch axis and go read a tutorial on jaxws, it will be 10 times easier.

  • Dynamic Invocation: Error The SOAP PA receives a SOAP Fault from SOAP serve

    Hi All,
    I am trying to run the sample code "Dynamic Invocation of Oracle9i Web Services using Oracle UDDI registry"
    I was able to run the web services, publish them, and inquiry them using local UDDI registry.
    However, while invoking any method provided by the web services using the inovk method I get the following error
    oracle.j2ee.ws.client.WebServiceProxyException: Invocation failed 5,100: The SOAP PA receives a SOAP Fault from SOAP server
    Can anybody help me please?
    Regards,
    S.Al Shamsi

    It looks like the problem is occuring on the server side. I guess you have included the stacktrace from the client, can you get hold of the server side stacktrace?

  • Reg@ Dynamic invocation of Webservices using an Single Invoke

    Hi ,
    I am trying to implement Dynamic invocation of webservices using a single Invoke .
    Say , i have three webservices = WebA,WebB and Webc .Based on Logic , i need to invoke either of the webservice with an single Invoke .
    In [  ws-addressing.xsd ] there are different elements ,"Address" is for endpoint URL.PortType??ServiceName ?? .
    If i need to make use of this XSD can any one help me to map the WSDL components to this XSD Or lease suggest options if any ??
    Regards ,
    Naga

    http://blogs.oracle.com/dasoa/2010/09/11g_dynamic_partnerlink_example.html
    see the article he's refering too
    eventually you need something like :
    <assign>
    <copy>
    <from>
    <EndpointReference xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing">
    <Address>http://localhost:9700/orabpel/default/UnitedLoan</Address>
    <ServiceName
    xmlns:ns1="http://services.otn.com">ns1:UnitedLoan</ServiceName>
    </EndpointReference>
    </from>
    <to variable="partnerReference"/>
    </copy>
    </assign>

  • Array of String for input paramter + dynamic invocation

    Does anybody know a place I can find an example of web service
    using the following methods:
    1. Array of String as input parameter
    2. Client uses dynamic invocation
    Specifically, 1. how do I define the parameter type in web-services.xml?
    2. how do I refer to the type in a client code?
    Thanks,
    Hong

    Hello,
    The doclitparam interop round 3 example does a echo string array.
    http://dev2dev.bea.com/managed_content/direct/webservice/r3server.zip
    Also there is a DII example in the WebService Wizard's archive:
    http://dev2dev.bea.com/managed_content/direct/webservice/wswa.html#qz29
    HTH,
    Bruce
    Hong wrote:
    Does anybody know a place I can find an example of web service
    using the following methods:
    1. Array of String as input parameter
    2. Client uses dynamic invocation
    Specifically, 1. how do I define the parameter type in web-services.xml?
    2. how do I refer to the type in a client code?
    Thanks,
    Hong

  • Step by step installation for Web Services Dynamic Invocation application?

    please let me know the step by step process to install the Web Services Dynamic Invocation application Sample code.The install.htm that comes with the download does not give enough information.
    Thanks in Advance
    Shyam

    Sorry for the confusion,i got hold of the right document.
    Thanks
    Shyam

  • Using service Locator pattern to dynamically access remote EJBs

    Hi All,
    Please help to guide me how I can use a service locator to retrieve a remote object (residing on another application but on same domain) .
    I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO)). Each EJB implementation implements its own remote/local interface that extends this global POJO interface.
    I have two J2ee-Applications on same domain. J2EE-Application 1 has an EJB module (EJB Module 1) that intends to access an EJB Module (EJB Module 2) in J2EE-Application 2. Following observations:
    1. Dependency Injection fails if (include the EJB Module 2 jar in J2EE-Application 1). Reason App Server complains the EJB has been deployed (Deployment fails)
    2. Dependency Injection works if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1).Positive Observation (Deployment success and DI also success)
    3.Using Service Locator to retrieve the remote object if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1). Negative and Positive Observation.
    Positive Observation: Using dependency injection I can still retrieve the Remote Object
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Negative Observation:
    The Service Locator lookup to this same remote object with Successful Dependency Injection fails (An Ejb in a different application).
    Can't retrieve the Remote Object with Service Locator. Message from Server:.
    NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
    Thanks in advance

    "I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO))"
    If you're calling ejbs from other ejbs or servlets, the same could probably be acomplished by using dependency injection (@EJB) in a number of instance variables typed with different remote/local interfaces or even with different beanName attributes (for when more than one bean implements the same managed interface in the same app - not sure how it works outside the same jee app...) , and dinamically selecting one of them; or encapsulating those injected variables into a stateless ejb as your service locator to make them accessible from POJOs too (which, due to concurrent acess, wouldn't work for statefull ejbs references...).
    Anyway, using the jndi lookup service locator pattern seems ok in this case.
    What doesn't seem ok, given the nature of the error for the negative observation - jndi context initialization - is that
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Can you check your code and reconfirm that you're using the same context initialization code for both the positive and negative observations ?

  • Dynamic invocation of javac with custom class path.

    To all the Java Gurus out there,
    Consider the following classes:
    XYZ/test/TestUtil.java
    package test;
    class TestUtil {
      void useMe() {
    }ABC/test/Test.java
    package test;
    public class Test {
      public static void main(String[] args) {
        TestUtil t = new TestUtil();
         t.useMe();
    }The class Test uses package private access to the TestUtil.useMe() method. Then the Test class is packaged into test.jar and the TestUtil class is packaged into testutil.jar.
    Our application uses a custom class loader architecture where the test.jar is loaded by class loader "X" and testutil.jar is loaded by class loader "Y". Also Y is the parent class loader of X. When the main() of Test class is run it results into IllegalAccessException as the package private method is being accessed from different class loaders.
    We are currently using a dynamic way to detect the dependency between test.jar and testutil.jar and generating the classpath argument to the "javac" ant task which dyncamically invokes the sun.tools.javac.Main class. So while compiling Test class the following command line is generated:
    javac -classpath XYZ/testutil.jar Test.java
    It compiles fine assuming that the Test class and the TestUtil class are loaded by the same class loader but at runtime this fails.
    Is there a way to make "javac" use our runtime class loader architecture to instead of static classpath, so that the access violation is captured at compile time?
    Any help is appreciated.
    Ravi
    PS: If this is not the right forum please point me to the right place to post this questions.

    Not that I'm aware of - the Java Language is designed to be platform-independent so absolute file paths which is a specific feature of various file systems would naturally not to be mixed up with the object-oriented hierarchy structure.
    Just like a compiler wouldn't check if a file exists in
    new File("<FilePath>")I don't think you can get compile-time checks for what you have wanted.
    Hope this helps~
    Alex Lam S.L.

  • Dynamic Invocation of popups ?

    I have a table which is created dynamically using the <netui-data:repeater > tags.
              I have made the 1st column to be a column of hyperlinks. Following is the code that I am using.
              <netui-data:repeaterItem>
              <tr class="contenteven" onmouseover="this.className='mouseovercolor'" onmouseout="this.className='mouseoutcolor'">
              <td><span><netui:label id=" %i++;%>" styleClass="labell" value="{container.item.strSR_NBR}" >
              </netui:label></td>
              <td align="center"><netui:label value="{container.item.strDATE}">
              </netui:label></td>
              <td align="center"><netui:label value="{container.item.strNAME}">
              </netui:label></td>
              </tr>
              </netui-data:repeaterItem>
              It prints:
              SR# DATE NAME
              15-34534-345 2004/09/27 Smith Will
              15-34534-333 2004/09/27 JOHN Brawny
              15-34534-332 2004/09/27 JOEY TRIBIANNI
              Please keep in mind that the table length will vary everytime.
              What I want is that, on clicking the 1st row 1st column, it should open a page which will display more information about row 1.
              I just don't know how can I keep track of the row which the user will click. I have tried various options but haven't got it to work yet. Please let me know if you have ay more suggestions.
              Thanks in advance!

    It looks like "{container.item.strSR_NBR}" is the unique identifier for each of your items. So, it seems like what you need to do is construct a URL that includes that id as a request parameter. Something like:
              <netui:anchor action="..." target="details">
                  <netui:parameter name="srNbr" value="{container.item.strSR_NBR}"/>
                  <netui:label value="{container.item.strSR_NBR}" ... />
              </netui:anchor>                    Kris

  • Dynamic invocation method

    Dear all,
    Any hints in dynamic calling a method for an assigned class like..
    myclass a=new myclass();
    a.setcolor("red");
    String mymethodname="getcolor";
    how to call a."mymethodname"??
    If using the Class.forName, and getMethods(), then I need to use "invoke" for every method before calling the dynamic calling method. Any simpler way?
    regards,
    coder

    No, you have to use refection.
    MyColourfulObject a = new MyColourfulObject();
    Class clazz = a.class;
    Method method = clazz.getMethod( "getColour", new Class[] {} );
    Object o = method.invoke( a, null );

  • Dynamic Invocation of portlets

    Hi,
    I have created portlets and able to deploy them in webcenter portal application successfully at run time.
    My qstn is, how can we invoke portlets dynamically(by Sending some parameters).........?
    Regards.

    Daniel,
    yeah its run-time,
    My Scenario is:
    I have two taskflows deployed as portlets,
    One TaskFlow having table containing a list of 3 rows,where each row represents a unique graph in another taskflow.
    Other TaskFlow contains three deployed graphs.
    Intially, second portlet must be empty...whenever user selects particular row in first portlet, respective graph should be displayed.
    Note: I thought use InterPortlet Communication between those two portlets and to pass some unique value(may be Id) as a parameter.
    Is there any other way of implementing...?
    Regards.

Maybe you are looking for

  • Setup problem please anyone help ~~ me !!!

    i was trying to setup adobe photoshop and i clicked setup.exe (file picture display like as a white paper) and it told me to choose application. so i dont know how to change or choose which program .. please anyone help me out on this..

  • Different zoom levels for different clips in the same project?

    Hi I am making a movie with videos from two different cameras. As a result some of the clips are cut down in size to a small portion of the screen. This can be solved if it is possible to use different zoom levels for different clips in the same proj

  • Stock Transfer Order IDoc

    Hello, I am confused with Idoc type for Stock Transfer Order & Standard PO. We are using ORDERS05 for both types of POs but problem is that in case of Stock Transfer Order , partner details(E1EDKA1) (LF) is blank. I think It should be filled with sup

  • Photos present in I Photo but not appearing in folders on hard disk

    OK so I have been warned about the idiosynchronies of I Photo but this? ...Help! I am able to successfully load from the camera into IPhoto and I am able to open the pics in Photoshop via various roundabout methods yet the new folders that appear in

  • Unknown error during manual creation Inbound Delivery in EWM

    Hello all, I'm building a demo for an SAP EWM system. It's installed on an existing SCM system, and is connected to ECC 6.0. The replication of Inbound Deliveries from ERP to EWM is going fine. However, when I try to create an Inbound Delivery in EWM