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 );

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]

  • 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?

  • 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

  • CLOBs and Dynamic SQL method 4

    We have just added CLOBs ( select_dp->T == 112 ) to our applications. We have a application tier server that is a Pro*C program that reads and iterprets some "extended" .sql files. We this server uses dynamic sql method 4, with host arrays, etc. The docs say you cannot do a FETCH FOR <value> with CLOBs, but you can ALLOCATE and FREE the clobLocator with a FOR clause. What good is the ALLOCATE and FREE "FOR" if you can't FETCH with a FOR ?? Can you really select clobs along with typical varchars??

    Can you tell me exactly where are you going to use the Dynamic SQL method 4 ? so that i can help you in using the method.
    Thiagu.

  • 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.

  • 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

  • How to create dynamically a method of a class??

    I would like to create dynamically a method of a class. Is this possible?
    By means of a report I would like to choose a class, to which the defined method should be added and after that I would like to define the name of the method and its parameters. The result should be, that the method is added to the selected class.
    How to do this?
    Regards
    Christian

    Christian,
    looks like an interesting development project. Though I share the doubts Rich has.
    Anyway, what you could possibly do is, start a runtime analysis for SE24, open an existing class, create a new method including desired interface parameters.
    Then analyze it and see what functions/methods are used.
    But It might be more complex than expected.
    Regards,
    Clemens

  • 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.

  • 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>

  • Dynamically invoke methods of abstract class?

    Hi,
    I am using reflection to write a class (ClassA) to dynamically invoke methods of classes. I have an abstract class (ClassB) that has some of the methods already implemented, and some of the methods that are declared abstract. Is there any way that I can:
    (a) invoke the methods that are already implemented in ClassB;
    (b) I have another class (ClassC) that extends ClassB, some of the methods are declared in both classes. Can I dynamically invoke these methods from ClassB?
    Thanks in advance,
    Matt.

    Ok, the program is quite long, as it does other things as well, so I'll just put in the relevant bits.
    What I have is a JTree that displays classes selected by the user from a JFileChooser, and their methods.
    // I declare a variable called executeMethod
    private static Method executeMethod;
    // objectClass is a class that has been chosen by the user.  I create a new instance of this class to execute the methods.
    Object createdObject = objectClass.newInstance();
    // methodName is the method selected by the user.  objectClassMethods is an array containing all the methods in the chosen class.
    executeMethod = objectClassMethods[j].getDeclaringClass().getMethod(methodName, null);
    Object executeObject = executeMethod.invoke(createdObject, new Object[]{});Ok, here are the test classes:
    public abstract class ClassB{
         private int age;
         private String name;
         public ClassB(){ age = 1; name="Me";}
         public int getAge(){ return age; }
         public String getName(){ return name; }
         public void PrintAge(){System.out.println(age);}
         public void PrintName(){System.out.println(name);}
         public abstract void PrintGreeting();
    public class ClassC extends ClassB{
         public ClassC(){super();}
         public void PrintAge(){
              System.out.println("I am " + getAge() + " years old.");
         public void PrintGreeting(){
           System.out.println("Hello");
    }Now, I can print out the PrintAge method from ClassC (i.e. have it output "Hello" to the command line, how can I, say, get it to output the result of PrintName from ClassB, this method does not appear in ClassC. As you can see at the top, I can create a new instance of a normal method (in this case, ClassC), and have it output to the command line, but I know that I can't create a new instance of an abstract class. And since PrintName is implemented in abstract class ClassB, how do I get it to output to the command line?
    Thanks,
    Matt.

  • 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

  • Why can't a reentrant dynamic dispatch method preallocate clones?

    Does anybody know why a reentrant dynamic dispatch method cannot preallocate clones? The VI breaks unless you set shared clones.
    =====================
    LabVIEW 2012
    Solved!
    Go to Solution.

    nathand wrote:
    A bit more information here: http://lavag.org/topic/10539-reentrant-vi-with-dynamic-input-terminal-must-use-share-clones-between-...
    I have to admit.  Steve Mercer explained it to me at a LUG (OK to the LUG) I'm still betting that this will eventaully be worked around by LabVIEW R&D.  When the use cases make the investment worthwhile
    Jeff

  • 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

  • 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.

Maybe you are looking for

  • Are you sure you want to shut down your computer now?

    I keep getting the subject message when I start up the computer. The only way I can get rid of of the message is if I keep rebooting the system for a while. Any one have any ideas as to what is causing this??? Thanks Model Name: Mac Pro Model Identif

  • How can I change my Apple ID for iCloud on iPhone 5 with iOS7?

    How can I change my Apple ID for iCloud on iPhone 5 with iOS7? When I updated to iOS7 it kept my old ID on some features and my new one on others. I was able to change my Apple ID on all apps except iCloud. I don't have the original email account I u

  • Java.lang.class not found exception: com.mysql.jdbc.Driver

    Hi everyone, I am using Jdk 1.5.0 , Connector/J 3.1 , Mysql 4.1.8 . When i try to connect to mysql i got the subject mentioned error i had alredy copied mysql-connector-java-3.1.8-bin-g.jar full path in my class path , butstill the same error is comi

  • Export destination picker: allow entering of path

    In the Export->Export Location->Choose->Browse for Folder, there is no option to paste a path directly. With most other programs, I find this the most efficient method. I have a folder open in another window, and all I have to do is copy and paste th

  • How to reinstall the OS lyon in a MacBook Air

    Hello A few days ago, I erase the MacBook Air HD. I erased the Lyon OS too. Now I have tried to reinstall it but the laptop doesn´t recongnize the wifi network. I went to another place to conect it to another wifi and it begun to download something.