Java String to Type
<p>I have an XML defined which provides a payload path to a serialized XML. I would like to take these parameters and create an object and call a method in a class. What is the best approach to do this in Java?</p>

<pre><code>XML
&lt;RequestObjectType&gt;com.test.model.QueryType&lt;/RequestObjectType&gt;
&lt;Class&gt;com.test.api.Query&lt;/Class&gt;
&lt;Method&gt;generalQuery&lt;/Method&gt;


public void callRequestViaObj(String payloadXML, String payloadType, String api_className, String method){
    Class c_payloadType = Class.forName(payloadType);
    Class c_apiClass = Class.forName(api_className);
    JAXBElement&lt;c_payloadType&gt; elemreq = (JAXBElement&lt;c_payloadType&gt;) JaxbUtils.XMLtoObj( payloadXML, JAXBContext.newInstance(c_payloadType) );
    c_payloadType qreq = (c_payloadType) (elemreq.getValue());

    //Would like to do something like this...
    c_payloadType.newInstance().callMethod(method).with(qreq);
}
</code></pre>
