I have to write a method wich can use webservices dynamically simply by passing the webservice full qualified class name as a String argument. I have a getPort method in my webservice class. I have written a small code snippet to get all the signatures of the method. Here is the output:
Méthode 1
javax.xml.namespace.QName
java.lang.Class
Méthode 2
javax.xml.ws.EndpointReference
java.lang.Class
[Ljavax.xml.ws.WebServiceFeature;
Méthode 3
java.lang.Class
[Ljavax.xml.ws.WebServiceFeature;
Méthode 4
java.lang.Class
Méthode 5
javax.xml.namespace.QName
java.lang.Class
[Ljavax.xml.ws.WebServiceFeature;
I assumed that the '[L' before class name was for 'abstract'. So i wrote this method:
public static Class<?>[] getTypes(Object[] args){
Class<?>[] paramTypes = null;
if(args != null)
{
paramTypes = new Class[args.length];
for(int i=0;i<args.length;++i)
{
if(args[i] instanceof javax.xml.ws.soap.MTOMFeature){
paramTypes[i] = args[i].getClass().getSuperclass();
}
else{
paramTypes[i] = args[i].getClass();
}
}
}
return paramTypes;
}
But i have the following error:
Exception in thread "main" java.lang.NoSuchMethodException: com.****.****.****.****.****.****.getPort(java.lang.Class, javax.xml.ws.WebServiceFeature)
at java.lang.Class.getMethod(Class.java:1670)
at test.testws.createServiceSoapPort(testws.java:160)
at test.testws.main(testws.java:44)
If i delete the 'instance of' test i got this error:
Exception in thread "main" java.lang.NoSuchMethodException: com.****.****.****.****.****.****.getPort(java.lang.Class, javax.xml.ws.soap.MTOMFeature)
at java.lang.Class.getMethod(Class.java:1670)
at test.testws.createServiceSoapPort(testws.java:160)
at test.testws.main(testws.java:44)
I need some help to understand that in order to solve this problem. Thanks
Aucun commentaire:
Enregistrer un commentaire