mardi 7 avril 2015

How to get the actual type in javax.xml.ws.Holder using Java reflection?

I want to do the Following.

1) I run wsimport on a WSDL to generate Java code.

2) wsimport generates a Java interface that represents the WSDL interface.

3) I want to use reflection to discover the parameter classes and return type for the methods in the interface.



Shown below is the interface that wsimport has generated.



public interface Sample2 {
@WebMethod(action = "http://ift.tt/1IGfE8j")
public void getMeaning2(
@WebParam(name = "getMeaning21", targetNamespace = "http://ift.tt/1H22Nib", partName = "parameters1")
GetMeaning21 parameters1,
@WebParam(name = "getMeaning2", targetNamespace = "http://ift.tt/1H22Nib", partName = "parameters2")
GetMeaning2 parameters2,
@WebParam(name = "getMeaningResponse21", targetNamespace = "http://ift.tt/1H22Nib", mode = WebParam.Mode.OUT, partName = "parameters3")
Holder<GetMeaningResponse21> parameters3,
@WebParam(name = "getMeaningResponse2", targetNamespace = "http://ift.tt/1H22Nib", mode = WebParam.Mode.OUT, partName = "parameters4")
Holder<GetMeaningResponse2> parameters4);
}


My question is specific to the 2nd and 3rd parameters to the method getMeaning2. I am able to the get the parameters for the method using the reflection api. Method.getParameterTypes (note that this is actually a instance method).



Class<?>[] parameterTypes = method.getParameterTypes();


The 2nd and the 3rd elements of the array are of type javax.xml.ws.Holder class.



My question is how do I get the actual type (in this case GetMeaningResponse21.class and GetMeaningResponse2.class) from the parameterTypes[2] and parameterTypes[3]?






Aucun commentaire:

Enregistrer un commentaire