Hi All, I'm having a problem at the moment trying to invoke methods in local
classes located outside the project containing the DynamicInvoker. As the
classpath attribute is currently not supportted in the WSIF classes, I
extended the WSIFPort_Java class to add a hack to allow specifying where the
class is located. Below is the WSIFPort_Java method I've overridden in my
own class.
public java.lang.Object getObjectReference() throws WSIFException {
Trc.entry(this);
Object objRef = null;
boolean localClass = true;
try{
objRef = super.getObjectReference();
}
catch(WSIFException wEx){
localClass = false;
System.out.println("Could not find class in current work
environment, checking local drives");
}
if (!localClass) {
JavaAddress address = null;
try {
ExtensibilityElement portExtension =
(ExtensibilityElement)
this.getPortModel().getExtensibilityElements().get(0);
if (portExtension == null) {
throw new WSIFException("missing port extension");
}
address = (JavaAddress) portExtension;
String classPath = address.getClassPath();
if(classPath.indexOf("file://") < 0)
classPath = "file://" + classPath;
URL[] classUrl = {new URL(classPath)};
String className = address.getClassName();
URLClassLoader urlClassLoader = new
URLClassLoader(classUrl);
Class c =
Class.forName(address.getClassName(),true,urlClassLoader);
// Class c = urlClassLoader.loadClass(className); produces
same class as above
objRef = c.newInstance();
} catch (Exception ex) {
Trc.exception(ex);
throw new WSIFException(
"Could not create object of class '" +
address.getClassName() + "'",
ex);
}
}
System.out.println(objRef.toString());
Trc.exit(objRef);
return objRef;
}
There are 2 possibilities when this method is called, either the class is
local to the project or if not it is in a different folder or drive.
When the class is not local the location of the class is obtained from the
classPath attribute in the WSDL file and a URLClassLoader class is
instantiated. The object I return from this looks the same as the object
returned when the super.getObjectReference() method is called, however, I
get an exception in the
operation.executeRequestResponseOperation(input, output, fault)
call in the DynamicInvoker if I use the object returned using the
URLClassLoader. This exception is below:
WSIF0005E: An error occurred when invoking the method 'getTestOutput'.
('Java')
org.apache.wsif.WSIFException:
[EMAIL PROTECTED] : Could not invoke
'getTestOutput'; nested exception is:
org.apache.wsif.WSIFException: Failed to invoke method 'getTestOutput'
at
org.apache.wsif.providers.java.WSIFOperation_Java.executeRequestResponseOper
ation(Unknown Source)
at
bait.adapter.utils.GenericDynamicServiceInvoker.invokeMethod(GenericDynamicS
erviceInvoker.java:249)
at
bait.adapter.utils.GenericDynamicServiceInvoker.callService(GenericDynamicSe
rviceInvoker.java:115)
at
bait.adapter.service_adapter_generated_classes.LocalTestClassServiceServiceA
dapter.invoke(LocalTestClassServiceServiceAdapter.java:37)
at MainTestDynamicInvoker.main(MainTestDynamicInvoker.java:31)
Caused by: org.apache.wsif.WSIFException: Failed to invoke method
'getTestOutput'
... 5 more
I'm at a bit of a loss as to why this happens and would appreciate any help
or suggestions.
Thanks as always in advance
Damien